前言

当用vue-cli 脚手架 打包压缩时,发现打包出来的css 没有被压缩,

Vue打包上线之后CSS没有压缩和不生效

所以查阅了些资料,下面用这个方法解决:

  1.首先注释掉webpack.prod.conf.js中下面的代码

Vue打包上线之后CSS没有压缩和不生效

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

2.然后在utils.js中添加, minimize:true

Vue打包上线之后CSS没有压缩和不生效

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

 这样 打包出来的css 就被压缩了

 

当然我也有点疑惑:

safe: true 这个插件 是什么意思 咦,求解释下

相关文章:

  • 2021-12-01
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-24
  • 2021-12-13
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
相关资源
相似解决方案