5

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

> floema@1.0.0 start
> npm run development


> floema@1.0.0 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 !

natzzzz
  • 53
  • 1
  • 4

2 Answers2

8

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,
    },
  },
};
louisch
  • 176
  • 10
0

on webpack.config.development.js page

devServer: {
 devMiddleware: {
  writeToDisk: true,
 },
},
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 24 '23 at 03:01