项目场景:
执行npm run build 的时候出现
CssSyntaxError: ...\static\css\app.613b694116dc60661fb79115beb867e6.css:1118:1: Unknown word
问题描述
CssSyntaxError: C:\Users\86150\Desktop\demo\graduationDesign\static\css\app.613b694116dc60661fb79115beb867e6.css:1118:1: Unknown word
at Input.error (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\input.js:128:16)
at Parser.unknownWord (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:561:22)
at Parser.decl (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:233:16)
at Parser.other (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:131:18)
at Parser.parse (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:75:16)
at parse (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parse.js:17:12)
at new LazyResult (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\lazy-result.js:64:16)
at Processor.<anonymous> (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\processor.js:142:12)
at Processor.process (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\processor.js:121:23)
at creator.process (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\postcss.js:148:43)
at OptimizeCssAssetsPlugin.processCss (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\index.js:63:19)
at Object.processor (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\optimize-css-assets-webpack-plugin\index.js:29:23)
at C:\Users\86150\Desktop\demo\graduationDesign\node_modules\last-call-webpack-plugin\index.js:139:8
at arrayEach (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\lodash\_arrayEach.js:15:9)
at forEach (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\lodash\forEach.js:38:10)
at LastCallWebpackPlugin.process (C:\Users\86150\Desktop\demo\graduationDesign\node_modules\last-call-webpack-plugin\index.js:136:3) {
reason: 'Unknown word',
解决方案:
1、将错误信息记住:app.613b694116dc60661fb79115beb867e6.css:1118:1: Unknown word。
2、找到webpack.prod.conf.js文件注释以下代码:
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false } }
: { safe: true }
}),
3、重新运行npm run build 命令
4、打开错误信息中提到的文件,并找到报错的代码在哪里,在你的文件上修改
5、修改完成后打开注释重新运行命令