gpt4 book ai didi

使用 writeToDisk 时 Webpack 无效的选项对象

转载 作者:行者123 更新时间:2023-12-05 01:53:45 24 4
gpt4 key购买 nike

我正在尝试将 webpack 用于我的 Web 开发项目,但不知道如何使用 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? }

谢谢!

最佳答案

https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md 中所述和 https://github.com/webpack/webpack-dev-server/issues/3768 , 选项 writeToDisk 被移动到 devServer.devMiddleware ,所以现在需要这样配置:

module.exports = {
devServer: {
devMiddleware: {
writeToDisk: true,
},
},
};

关于使用 writeToDisk 时 Webpack 无效的选项对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71048875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com