Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack dev server does not recognize watchContentBase as valid option

Webpack dev server does not recognize watchContentBase as a valid option. Is watchContentBase deprecated? If so what is the alternative? Below is the configuration of my Webpack dev server:

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

When I run my server, I get the following error.

Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.

  • options has an unknown property 'watchContentBase'. 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? }
like image 720
S J Avatar asked Jul 11 '26 02:07

S J


2 Answers

In the newer version, contentBase has been replaced with static

devServer:{
    static: path.resolve(__dirname, 'src'),
    port: 8080,
    open: true,
    hot: true
}
like image 82
Kamran Asgari Avatar answered Jul 13 '26 19:07

Kamran Asgari


Just rename contentBase to static.

like image 29
Nevolgograd Avatar answered Jul 13 '26 19:07

Nevolgograd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!