![](/img/trans.png)
[英]Webpack does not create output file (not using webpack-dev-server)
[英]Does “--content-base” is deprecated from webpack-dev-server while using webpack v2.2?
我开始迁移webpack 2.2,在配置webpack-dev-server时遇到问题,我的构建脚本是
"build": "webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/"
低于错误
ERROR in multi (webpack)-dev-server/client?http://localhost:8080 ./src/app/index.js content-base ./src
Module not found: Error: Can't resolve 'content-base' in 'E:\React\react-basics'
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/app/index.js content-base ./src
ERROR in multi (webpack)-dev-server/client?http://localhost:8080 ./src/app/index.js content-base ./src
Module not found: Error: Can't resolve 'E:\React\react-basics\src' in 'E:\React\react-basics'
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/app/index.js content-base ./src
webpack: Failed to compile.
好像我在没有内容库的情况下设置脚本正常工作
"build": "webpack -d && cp src/index.html dist/index.html && webpack-dev-server
为什么会出现此错误,如何为webpack 2.2设置webpack-dev-server?
我建议您在webpack配置文件中配置devServer设置:
范例 :
devServer: {
// All options here: https://webpack.js.org/configuration/dev-server/
// enable HMR on the server
hot: true,
// match the output path
contentBase: resolve(__dirname, '../dist'),
// match the output `publicPath`
publicPath: '/',
// Enable to integrate with Docker
//host:"0.0.0.0",
port: 3000,
historyApiFallback: true,
// All the stats options here: https://webpack.js.org/configuration/stats/
stats: {
colors: true, // color is life
chunks: false, // this reduces the amount of stuff I see in my terminal; configure to your needs
'errors-only': true
}
},
你可以从类似的package.json invode的WebPack-dev的服务器在这里 :
"start": "set NODE_ENV=development && webpack-dev-server --open --config ./webpack/webpack.config.dev.js",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.