using an options object that does not match the API schema.
wanglimindeMacBook-Air:8-5 wanglimin$ npm run build
> 8-5@1.0.0 build /Users/wanglimin/Desktop/resource/8-5
> cross-env NODE_ENV=prod webpack --config config/webpack.config.prod.js
Invalid options object. Terser Plugin has been initialized using an options object that does not match the API schema.
- options has an unknown property 'sourceMap'. These properties are valid:
object { test?, include?, exclude?, terserOptions?, extractComments?, parallel?, minify? }
ValidationError: Invalid options object. Terser Plugin has been initialized using an options object that does not match the API schema.
at validate (/Users/wanglimin/Desktop/resource/8-5/node_modules/_schema-utils@3.0.0@schema-utils/dist/validate.js:104:11)
at new TerserPlugin (/Users/wanglimin/Desktop/resource/8-5/node_modules/_terser-webpack-plugin@5.1.3@terser-webpack-plugin/dist/index.js:131:31)
at Object.<anonymous> (/Users/wanglimin/Desktop/resource/8-5/config/webpack.config.prod.js:15:13)
at Module._compile (/Users/wanglimin/Desktop/resource/8-5/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (/Users/wanglimin/Desktop/resource/8-5/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 8-5@1.0.0 build: `cross-env NODE_ENV=prod webpack --config config/webpack.config.prod.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 8-5@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/wanglimin/.npm/_logs/2021-06-21T22_38_01_407Z-debug.log
报错形式如上,看提示可能让我检查配置信息,查了几遍和视频上一样啊
These properties are valid:
object { test?, include?, exclude?, terserOptions?, extractComments?, parallel?, minify? }
ValidationError: Invalid options object. Terser Plugin has been initialized using an options object that does not match the API schema.
webpack.config.prod.js 如下
const webpackMerge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.config.base')
const TerserWebpackPlugin = require('terser-webpack-plugin')
const webpackConfig = webpackMerge(baseWebpackConfig, {
mode: 'production',
stats: {
children: false,
warnings: false
},
optimization: {
minimizer: [
new TerserWebpackPlugin({
terserOptions: {
warnings: false,
compress: {
warnings: false,
drop_console: false,
dead_code: true,
drop_debugger: true,
},
output: {
comments: false,
beautify: false,
},
mangle: true,
},
parallel: true,
sourceMap: false,
})
],
splitChunks: {
cacheGroups: {
commons: {
name: 'commons',
chunks: 'initial',
minChunks: 3,
enforce: true
},
},
},
}
})
module.exports = webpackConfig
25
收起
正在回答
2回答
我写了一个示例应用https://git.imooc.com/class-70/webpack-v5-nodemon
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星