rollup-plugin-css-only icon indicating copy to clipboard operation
rollup-plugin-css-only copied to clipboard

How to minify the output css?

Open BryanAdamss opened this issue 4 years ago • 1 comments

Is there any way to compress the output css file?

plugins: [
    nodeResolve(),
    commonjs(),
    babel(getBabelOptions(isModern)),
    vue({
      css: false,
      compileTemplate: true
    }),
    css({ output: 'index.css' }),
    banner(getBanner()),
    terser(getTerserOptions())
  ]

BryanAdamss avatar May 11 '21 11:05 BryanAdamss

@BryanAdamss I did this and it worked well (hope it helps)

import fs from 'fs';

// 1. using csso for minifying the css
import { minify } from 'csso';

export default {
  plugins: [
    css({
      // 2. on output do the minification 
      output: function (styles) {
        fs.writeFileSync(`dist/${name}.css`, minify(styles).css);
      },
    }),
    vue({
      css: false,
    }),
  ]
};

skiano avatar May 18 '22 15:05 skiano

Here's a new way to do it, based on documentation:

css({ minify: true })

EdKo2001 avatar Jun 03 '24 09:06 EdKo2001