解决vue 打包出错问题

使用VSCode运行 npm run build 报错

\ building for production...Error processing file: static/css/app.4ebb9f9883beef537466e865360a12aa.css
(node:7512) UnhandledPromiseRejectionWarning: CssSyntaxError: D:\work\memberweb-ui\static\css\app.4ebb9f9883beef537466e865360a12aa.css:703:6: Unknown word
    at Input.error (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\input.js:130:16)
    at Parser.unknownWord (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:563:22)
    at Parser.decl (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:235:16)
    at Parser.other (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:133:18)
    at Parser.parse (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parser.js:77:16)
    at parse (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\parse.js:17:12)
    at new LazyResult (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\lazy-result.js:60:16)
    at Processor.<anonymous> (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\processor.js:138:12)
    at Processor.process (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\processor.js:117:23)
    at Function.creator.process (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\postcss.js:148:43)
    at OptimizeCssAssetsPlugin.processCss (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\index.js:63:19)
    at Object.processor (D:\work\memberweb-ui\node_modules\optimize-css-assets-webpack-plugin\index.js:29:23)
    at D:\work\memberweb-ui\node_modules\last-call-webpack-plugin\index.js:139:8
    at arrayEach (D:\work\memberweb-ui\node_modules\lodash\_arrayEach.js:15:9)
    at forEach (D:\work\memberweb-ui\node_modules\lodash\forEach.js:38:10)
    at LastCallWebpackPlugin.process (D:\work\memberweb-ui\node_modules\last-call-webpack-plugin\index.js:136:3)
(node:7512) 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:7512) [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命令打包后,会自动压缩js、css等代码。从上面的报错信息不难看出,是压缩css代码时出错了

解决方法

找到webpack.prod.conf.js文件,
注释以下代码
//const OptimizeCSSPlugin = require(‘optimize-css-assets-webpack-plugin’)
//new OptimizeCSSPlugin({
// cssProcessorOptions: config.build.productionSourceMap
//? { safe: true, map: { inline: false } }
// : { safe: true }
//}),

你可能感兴趣的:(Vue.js)