Vue npm run build 错误 CssSyntaxError:xxxx.Unknown word

错误提示

building for production...Error processing file: static/css/app.df86e347a94aed52aa7bb0b865b3f053.css
(node:8868) UnhandledPromiseRejectionWarning: CssSyntaxError: D:\Workspace\TestExercise\vueDemo\vue-module\static\css\app.df86e347a94aed52aa7bb0b865b3f053.css:49:45: Unknown word
    at Input.error (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\input.js:130:16)
    at Parser.unknownWord (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:563:22)
    at Parser.decl (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:235:16)
    at Parser.other (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:133:18)
    at Parser.parse (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:77:16)
    at parse (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parse.js:17:12)
    at new LazyResult (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\lazy-result.js:60:16)
    at Processor.<anonymous> (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\processor.js:138:12)
    at Processor.process (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\processor.js:117:23)
    at Function.creator.process (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\postcss.js:148:43)
    at OptimizeCssAssetsPlugin.processCss (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\index.js:63:19)
    at Object.processor (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\optimize-css-assets-webpack-plugin\index.js:29:23)
    at D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\last-call-webpack-plugin\index.js:139:8
    at arrayEach (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\lodash\_arrayEach.js:15:9)
    at forEach (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\lodash\forEach.js:38:10)
    at LastCallWebpackPlugin.process (D:\Workspace\TestExercise\vueDemo\vue-module\node_modules\last-call-webpack-plugin\index.js:136:3)
(node:8868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
(rejection id: 2)
(node:8868) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

错误介绍

这个错误是执行npm run build 编译打包时候出现的报错。
第一次看到的确很懵,告诉我这个问题件有个unkown word 有个不识别的单词,估计就是什么单词或者写错了吧。现在关键的是在dist目录下没有这个css文件。都没有文件生成。

错误提示

解决方法

遇到这种情况,一个项目要是出现这种单词写错了,而且npm run dev 的时候也不报错。直接去一个文件一个文件的找肯定遭不住、所以找了很久的资料,终于看到一个大佬说修改一下webpack.prod.conf里的一段代码就可以了。然后重新打包就能打包成功。最后再到生成的css文件中去看到在多少行。再去对应的源文件里面修改。
// 在webpack.prod.conf中找到这个暂时注释掉。解决问题后再放开
//new OptimizeCSSPlugin({
// cssProcessorOptions: config.build.productionSourceMap
//? { safe: true, map: { inline: false } }
// : { safe: true }
//}),

最后解决问题后。及得把注释放开。我的问题是在样式里面用了
//注释

posted @ 2020-04-21 14:58  清梦徐徐丶莫  阅读(5750)  评论(0编辑  收藏  举报