Webpack 1.x 升级到3.5.5踩坑指南
1、在webpack.base.conf.js中的配置(已经是github/issue中的解决办法https://github.com/webpack-contrib/css-loader/issues/362,但在npm run build中仍报错:Module build failed: Unknown word):
module: {
rules: [
{
test: /\.css$/,
use: [
"style-loader",
"css-loader"
]
},
{
test: /\.less$/,
use: [
"style-loader",
"css-loader",
"less-loader"
]
},
]
}
把css的规则去掉之后,build没有报错,但dev报错了:
You may need an appropriate loader to handle this file type
2、把package.json改来改去,结果报了个错
> erp-web@1.0.0 dev /Users/sherry/Documents/巴图鲁/test/erp-web/erp-web-publish/src/main/webapp/web
> node build/dev-server.js
module.js:487
throw err;
^
Error: Cannot find module 'tapable'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/sherry/Documents/巴图鲁/test/erp-web/erp-web-publish/src/main/webapp/web/node_modules/webpack/lib/Compiler.js:8:17)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
只能执行:
npm cache clear --force
rm -rf node_modules
npm install