報錯信息:
[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 'contentBase'. These properties are valid:
原因:
webpack配置代碼:
devServer: {
contentBase: __dirname,
},
其實信息提示得挺明白了,就是contentBase這個屬性不能用了。
解決方案:
因為contentBase已經棄用了,所以正確應該改為:
devServer: { // contentBase: __dirname, static: { directory: path.join(__dirname, "dist"), }, },