Intuitively, I'd think that the writeToDisk
option could be configured under configureDevServerOptions
, but trying to do so yields this error:
Running webpack-dev-server ...
WARNING Webpack is already provided by Webpack Encore, also adding it to your package.json file may cause issues.
WARNING Passing an absolute URL to setPublicPath() *and* using the dev-server can cause issues. Your assets will load from the publicPath (http://localhost:9091/build/) instead of from the dev server URL.
[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?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, setupExitSignals?, static?, watchFiles?, webSocketServer? }
error Command failed with exit code 2.
The value has also been attempted to be set through the getWebpackConfig()
object, but the same error gets generated.
The next way to attack this could then be through devMiddleware
due to this writeToDisk
option. This produces this error:
Running webpack-dev-server ...
WARNING Webpack is already provided by Webpack Encore, also adding it to your package.json file may cause issues.
WARNING Passing an absolute URL to setPublicPath() *and* using the dev-server can cause issues. Your assets will load from the publicPath (http://localhost:9091/build/) instead of from the dev server URL.
TypeError: Cannot set property 'writeToDisk' of undefined
- webpack.config.js:99 Object.<anonymous>
C:/path/to/project/webpack.config.js:99:41
- apply-options-callback.js:13 module.exports
[project]/[@symfony]/webpack-encore/lib/utils/apply-options-callback.js:13:36
- config-generator.js:616 ConfigGenerator.buildDevServerConfig
[project]/[@symfony]/webpack-encore/lib/config-generator.js:616:16
- config-generator.js:60 ConfigGenerator.getWebpackConfig
[project]/[@symfony]/webpack-encore/lib/config-generator.js:60:74
- config-generator.js:631 module.exports
[project]/[@symfony]/webpack-encore/lib/config-generator.js:631:22
- index.js:1634 Encore.getWebpackConfig
[project]/[@symfony]/webpack-encore/index.js:1634:16
- EncoreProxy.js:51 Proxy.minDistance
[project]/[@symfony]/webpack-encore/lib/EncoreProxy.js:51:53
- webpack.config.js:126 Object.<anonymous>
C:/path/to/project/webpack.config.js:126:25
- v8-compile-cache.js:192 Module._compile
[project]/[v8-compile-cache]/v8-compile-cache.js:192:30
- loader:1153 Object.Module._extensions..js
node:internal/modules/cjs/loader:1153:10
error Command failed with exit code 1.
Since publicPath
is not in this dev server "schema," I have had to set the public path through setPublicPath
to the value in the warning, causing that warning to be generated.
The first warning is from setting my package.json
Webpack definition to webpack@^5.35
so other dependency warnings are not generated.
How can options not defined in the dev server schema be properly configured?
This can be accomplished using the copyFiles
function by just ensuring the whole build directory gets copied over in the dev-server
environment.