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语法错误,可是也找不到到底是哪里错误,最后只能如此解决,项目打包后可以正常上线)

你可能感兴趣的:(vue打包时候报错(压缩css错误) building for production...Error processing file: static/css/app.e8b75d3d19abc5bbb)