vue打包时候报错(压缩css错误) building for production...Error processing file: static/css/app.e8b75d3d19abc5bbb

报错信息如下

\ building for production...Error processing file: static/css/app.e8b75d3d19abc5bbbd9bd916f459f0d0.css

(node:16424) UnhandledPromiseRejectionWarning: CssSyntaxError: E:\simou\static\css\app.e8b75d3d19abc5bbbd9bd916f459f0d0.css:1995:6: Unknown word

    at Input.error (E:\simou\node_modules\optimize-css-assets-webpack-plugin\node_modules\postcss\lib\input.js:130:16)
.
.
.
(node:16424) 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:16424) [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.

在webpack.prod.conf.js中注释 (这是webpack压缩css的配置)

const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')

new OptimizeCSSPlugin({

      cssProcessorOptions: config.build.productionSourceMap

        ? { safe: true, map: { inline: false } }

        : { safe: true }

    }),

注释之后,可正常打包项目,但是css没有被压缩

在utils.js种添加minimize:true

const cssLoader = {
    loader: 'css-loader',
    options: {
      sourceMap: options.sourceMap,
      minimize:true
    }
  }

这样,项目就可以正常打包,css也可压缩

(搜索结果报错是css语法错误,可是也找不到到底是哪里错误,最后只能如此解决,项目打包后可以正常上线)

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值