Webpack 接入 extract-text-webpack-plugin
后运行报错
DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
WebApp\Project\node_modules\webpack\lib\Chunk.js:866
throw new Error(
^
Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
原因:依赖版本兼容问题,Webpack4.x 和 extract-text-webpack-plugin
3.x混用会报错。将 extract-text-webpack-plugin
升级到 4.x 即可。
yarn add extract-text-webpack-plugin@next
也可参照我的 package.json
进行设置
{
"name": "react-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack-dev-server --inline --progress --open --config config/webpack.dev.config.js",
"build": "webpack --config config/webpack.prod.config.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.10.5",
"@babel/preset-env": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"babel-loader": "^8.1.0",
"clean-webpack-plugin": "^3.0.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"html-webpack-plugin": "^4.3.0",
"url-loader": "^4.1.0",
"css-loader": "^1.0.0",
"node-sass": "^4.9.2",
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"webpack": "^4.16.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-merge": "^5.0.9"
},
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1"
}
}
欢迎批评指正