直观地说,我认为可以在configureDevServerOptions下配置writeToDisk选项,但尝试这样做会产生以下错误:
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.也曾尝试通过getWebpackConfig()对象设置该值,但生成了相同的错误。
由于this writeToDisk option,下一种攻击方式可能是通过devMiddleware。这会产生以下错误:
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.由于publicPath不在此开发服务器“模式”中,因此我必须将通过setPublicPath的公共路径设置为警告中的值,从而导致生成该警告。
第一个警告来自将我的package.json Webpack定义设置为webpack@^5.35,这样就不会生成其他依赖警告。
如何正确配置开发服务器模式中未定义的选项?
发布于 2021-08-26 22:11:01
这可以使用copyFiles函数来完成,只需确保在dev-server环境中复制整个构建目录即可。
https://stackoverflow.com/questions/68836756
复制相似问题