HTML5教程

vue打包报错UnhandledPromiseRejectionWarning: CssSyntaxError:

本文主要是介绍vue打包报错UnhandledPromiseRejectionWarning: CssSyntaxError:,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
building for production...Error processing file: static/css/app.b20c74dc5216e3341c47d1833529ecad.css
(node:9868) UnhandledPromiseRejectionWarning: CssSyntaxError: D:\workspace\h5-app\static\css\app.b20c74dc5216e3341c47d1833529ecad.css:35:7: Unknown word
    at Input.error (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\input.js:130:16)
    at Parser.unknownWord (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\parser.js:563:22)
    at Parser.decl (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\parser.js:235:16)
    at Parser.other (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\parser.js:133:18)
    at Parser.parse (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\parser.js:77:16)
    at parse (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\parse.js:17:12)
    at new LazyResult (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\lazy-result.js:60:16)
    at Processor.<anonymous> (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\processor.js:138:12)
    at Processor.process (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\processor.js:117:23)
    at Function.creator.process (D:\workspace\h5-app\node_modules\cssnano\node_modules\postcss\lib\postcss.js:148:43)
    at OptimizeCssAssetsPlugin.processCss (D:\workspace\h5-app\node_modules\optimize-css-assets-webpack-plugin\index.js:63:19)
    at Object.processor (D:\workspace\h5-app\node_modules\optimize-css-assets-webpack-plugin\index.js:29:23)
    at D:\workspace\h5-app\node_modules\last-call-webpack-plugin\index.js:139:8
    at arrayEach (D:\workspace\h5-app\node_modules\lodash\_arrayEach.js:15:9)
    at forEach (D:\workspace\h5-app\node_modules\lodash\forEach.js:38:10)
    at LastCallWebpackPlugin.process (D:\workspace\h5-app\node_modules\last-call-webpack-plugin\index.js:136:3)
(node:9868) 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(). To terminate the node process on u
nhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:9868) [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.

看到这个错误,一脸懵,不知道从何下手。
搜到这个答案https://blog.csdn.net/weixin_...

试着注释webpack 配置
/build/webpack.pro.conf.js

new OptimizeCSSPlugin({  
  cssProcessorOptions: config.build.productionSourceMap  
  ? { safe: true, map: { inline: false } }  
    : { safe: true }  
}),

然后真的可以了。

进入打包后的app.xxxx.css 文件 35:7: Unknown word

35行,果然发现错误,

r display:none;

这个r怎么回事?
删了只会,解开webpack配置,也可以正常打包了。

总结:
在去除代码压缩的配置之后,非常容易进行debug,查找代码错误行和列。进行精准定位。

这篇关于vue打包报错UnhandledPromiseRejectionWarning: CssSyntaxError:的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!