Invalid options object. Dev Server has been initialized using an options object

启动webpack报错:

[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:
   object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, static?, watchFiles?, webSocketServer? }

解决方法:

在webpack.config.js文件中

devServer: {
    // contentBase: "./public",
    static:'./public',
  }

Invalid options object. Dev Server has been initialized using an options object_第1张图片

 

注:在新版的webpack-dev-server中,contentBase已经被移除了,用static替代。

你可能感兴趣的:(webpack)