【发布时间】:2021-03-14 20:34:32
【问题描述】:
运行此命令时
npm run-script watch
我有这个错误
npm ERR! command sh -c webpack --watch -d --output ./target/classes/static/built/bundle.js
还有这个
[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$".
BREAKING CHANGE since webpack 5: The devtool option is more strict.
Please strictly follow the order of the keywords in the pattern.
我的 webpack.config.js
var path = require('path');
module.exports = {
entry: './src/main/js/App.js',
cache: true,
mode: 'development',
output: {
path: __dirname,
filename: './src/main/resources/static/built/bundle.js'
},
module: {
rules: [
{
test: path.join(__dirname, '.'),
exclude: /(node_modules)/,
use: [{
loader: 'babel-loader',
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}]
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.(png|svg|jpg|gif|eot|otf|ttf|woff|woff2)$/,
use: [
{
loader: 'url-loader',
options: {}
}
]
}
]
}
};
知道为什么吗?
使用
"webpack": "^5.25.0", "webpack-cli": "^4.5.0"
谢谢,
【问题讨论】: