rom*_*oms 72 webpack webpack-dev-server webpack-cli
当我将 webpack 升级到 4.0.0-beta.3 并运行时,npx webpack serve
出现以下错误:
[webpack-cli] Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration has an unknown property 'contentBase'. These properties are valid:
object { bonjour?, client?, compress?, devMiddleware?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, public?, setupExitSignals?, static?, transportMode?, watchFiles? }
Run Code Online (Sandbox Code Playgroud)
这是我的 webpack.config.js,适用于 3.11.2:
const path = require('path');
const ArcGISPlugin = require("@arcgis/webpack-plugin");
module.exports = {
mode: 'development',
entry: {
main: './app/main.js'
},
plugins: [
new ArcGISPlugin()
],
devServer: {
contentBase: './'
}
}
Run Code Online (Sandbox Code Playgroud)
我的 package.json 中的 devDependency:
"devDependencies": {
"@arcgis/webpack-plugin": "^4.18.0",
"dojo-typings": "^1.11.11",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^4.0.0-beta.3"
Run Code Online (Sandbox Code Playgroud)
我需要如何更新配置才能使最新版本正常工作?当我取出开发服务器对象时,服务器将运行,但提供不存在的 ./public 内容。
我是 webpack 的新手,所以我还不熟悉应用程序、配置和要求。
rom*_*oms 88
devServer: {
static: './'
}
Run Code Online (Sandbox Code Playgroud)
我应该更仔细地阅读错误。上面的对象使我的配置再次工作。
use*_*488 45
使用最新 Webpack v5 中已弃用的static
内容contentBase
devServer: {
static: {
directory: path.join(__dirname, "./")
},
Run Code Online (Sandbox Code Playgroud)
完整详细信息: https: //webpack.js.org/configuration/dev-server/#devserver
小智 11
devServer: {
static: {
directory: path.join(__dirname, "public")
},
compress: true,
port: 3010, // default 8000
},
Run Code Online (Sandbox Code Playgroud)
使用static: './directory-name'
而不是contentBase: './directory-name'
例子:
devServer: {
static: './dist'
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
61919 次 |
最近记录: |