在使用css-loader的minimize时报错:


webapck运行报错- css-loader minimize_html

ERROR in ./index.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./index.css)
Module build failed (from ./node_modules/css-loader/dist/cjs.js):
ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
- options has an unknown property 'minimize'. These properties are valid:
object { url?, import?, modules?, sourceMap?, importLoaders?, esModule? }
at validate (G:\Program Files\nodejs\node_global\node_modules\webpack\node_modules\schema-utils\dist\validate.js:104:11)
at Object.getOptions (G:\Program Files\nodejs\node_global\node_modules\webpack\lib\NormalModule.js:501:6)
at Object.loader (E:\前端\webpack\node_modules\css-loader\dist\index.js:31:27)
@ ./index.css 8:6-126 22:17-24 26:0-96 26:0-96 27:22-29 27:33-47 27:50-64
@ ./main.js 3:0-21

webapck运行报错- css-loader minimize_css_02

解决办法

移除minimize: true, 因为在webpack 3.0 之后以及 css-loader 1.0 以上已经将 minimize 这个属性去掉了。