我尝试在我的web开发项目中使用webpack,但不知道如何使用writeToDisk选项。
下面是我的webpack.config.development.js文件:
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')
}
})
运行npm start
的结果如下:
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? }
谢谢!
2条答案
按热度按时间sy5wg1nm1#
如https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md和https://github.com/webpack/webpack-dev-server/issues/3768中所述,选项
writeToDisk
被移动到devServer.devMiddleware
,因此现在需要这样配置:yyyllmsg2#
在webpack.config.development.js页面