Webpack 开发服务器无法将 watchContentBase 识别为有效选项

S J*_*S J 6 webpack webpack-dev-server

Webpack 开发服务器无法将 watchContentBase 识别为有效选项。已watchContentBase弃用吗?如果是这样,有什么替代方案?以下是我的 Webpack 开发服务器的配置:

devServer: {
    contentBase: path.resolve(__dirname, 'dist'),
    port: 8080,
    open: true,
    hot: true,
    watchContentBase: true,
}
Run Code Online (Sandbox Code Playgroud)

当我运行我的服务器时,出现以下错误。

选项对象无效。开发服务器已使用与 API 架构不匹配的选项对象进行初始化。

  • options 有一个未知属性“watchContentBase”。这些属性有效: object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, HistoryApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware ?,onBeforeSetupMiddleware?,onListening?,打开?,端口?,代理?,服务器?,setupExitSignals?,静态?,watchFiles?,webSocketServer?}

Cam*_*n A 11

在新版本中,contentBase已替换为static

devServer:{
    static: path.resolve(__dirname, 'src'),
    port: 8080,
    open: true,
    hot: true
}
Run Code Online (Sandbox Code Playgroud)


Иго*_*нов 6

只需重命名contentBase static.