Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack invalid options object when using writeToDisk

I'm trying to use webpack for my web development project, but can't figure out how to use the writeToDisk option.

Here's my webpack.config.development.js file:

const { merge } = require('webpack-merge')
const path = require('path')

const config = require('./webpack.config')

module.exports = merge(config, {
  mode: 'development',

  devtool: 'inline-source-map',

  devServer: {
    writeToDisk: true
  },

  output: {
    path: path.resolve(__dirname, 'public')
  }
})

And the result when I run npm start is the following:

C:\Users\natha\OneDrive\Documents\web\floema>npm start

> [email protected] start
> npm run development


> [email protected] development
> webpack serve --progress --config webpack.config.development.js

C:\Users\natha\OneDrive\Documents\web\floema\app C:\Users\natha\OneDrive\Documents\web\floema\assets C:\Users\natha\OneDrive\Documents\web\floema\styles
1% setup initialize[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?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? }

Thanks !

like image 270
natzzzz Avatar asked Sep 03 '26 17:09

natzzzz


1 Answers

As documented in https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md and https://github.com/webpack/webpack-dev-server/issues/3768, the option writeToDisk was moved to devServer.devMiddleware, so it needs to be configured like this now:

module.exports = {
  devServer: {
    devMiddleware: {
      writeToDisk: true,
    },
  },
};
like image 105
louisch Avatar answered Sep 06 '26 08:09

louisch