Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to minify the output css? #35

Open
BryanAdamss opened this issue May 11, 2021 · 2 comments
Open

How to minify the output css? #35

BryanAdamss opened this issue May 11, 2021 · 2 comments

Comments

@BryanAdamss
Copy link

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())
  ]
@skiano
Copy link

skiano commented May 18, 2022

@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,
    }),
  ]
};

@EdKo2001
Copy link

EdKo2001 commented Jun 3, 2024

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

css({ minify: true })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants