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_...css

試着註釋webpack 配置
/build/webpack.pro.conf.jshtml

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

而後真的能夠了。node

進入打包後的app.xxxx.css 文件 35:7: Unknown wordwebpack

35行,果真發現錯誤,web

r display:none;

這個r怎麼回事?
刪了只會,解開webpack配置,也能夠正常打包了。api

總結:
在去除代碼壓縮的配置以後,很是容易進行debug,查找代碼錯誤行和列。進行精準定位。promise

相關文章
相關標籤/搜索