admin管理员组文章数量:1291090
After updated the webpack devServer
package of my project from "webpack-dev-server": "3.11.2"
to "webpack-dev-server": "4.3.0"
I'm facing this issue when I start my project:
>> npm run start
> [email protected] start
> webpack serve --config webpack.dev.js
[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'writeToDisk'. These properties are valid:
object { allowedHosts?, bonjour?, client?, press?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, setupExitSignals?, static?, watchFiles?, webSocketServer? }
The changelog seems not to be updated and I've found only a couple of new options: More info here
How can I convert this "old" configuration file to the new one?
And if possible, where can I find the new configuration options?
webpack.dev.js:
const {merge} = require('webpack-merge');
const mon = require('./webpackmon.js');
const path = require('path');
module.exports = merge(mon, {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, './dist'),
press: true,
watchContentBase: true,
historyApiFallback: true,
https: false,
open: 'Firefox Developer Edition',
stats: {
colors: true,
},
port: 9002,
proxy: {
'/api': 'http://localhost:9000'
},
writeToDisk: true,
},
});
Thank you for your help
After updated the webpack devServer
package of my project from "webpack-dev-server": "3.11.2"
to "webpack-dev-server": "4.3.0"
I'm facing this issue when I start my project:
>> npm run start
> [email protected] start
> webpack serve --config webpack.dev.js
[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'writeToDisk'. These properties are valid:
object { allowedHosts?, bonjour?, client?, press?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, setupExitSignals?, static?, watchFiles?, webSocketServer? }
The changelog seems not to be updated and I've found only a couple of new options: More info here
How can I convert this "old" configuration file to the new one?
And if possible, where can I find the new configuration options?
webpack.dev.js:
const {merge} = require('webpack-merge');
const mon = require('./webpack.mon.js');
const path = require('path');
module.exports = merge(mon, {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, './dist'),
press: true,
watchContentBase: true,
historyApiFallback: true,
https: false,
open: 'Firefox Developer Edition',
stats: {
colors: true,
},
port: 9002,
proxy: {
'/api': 'http://localhost:9000'
},
writeToDisk: true,
},
});
Thank you for your help
Share Improve this question asked Sep 25, 2021 at 16:26 Yohan W. DunonYohan W. Dunon 5281 gold badge11 silver badges19 bronze badges1 Answer
Reset to default 9You simply use fields that are not allowed. Your dev-server should be written as such:
devServer: {
static: {
directory: path.join(__dirname, './dist')
},
press: true,
historyApiFallback: true,
https: false,
open: true,
hot: true,
port: 9002,
proxy: {
'/api': 'http://localhost:9000'
}
devMiddleware: {
writeToDisk: true,
},
},
// ps: you don't need 'static' for ./dist . DevServer is here to pile and hot reload the js code that is attached to the "root" node. The dist folder is supposed to contain your final build.
// to use writeToDisk, you'll need to install webpack-dev-middleware
// npm install webpack-dev-middleware --save-dev
本文标签: javascriptHow to use the new Webpack devServer configurationStack Overflow
版权声明:本文标题:javascript - How to use the new Webpack devServer configuration? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741500738a2382042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论