Xavier Bernadi
Xavier Bernadi

Reputation: 79

Compress CSS file in NUXT

I have a website made with NUXT (VUE framework) and when compiling it, it doesn't compress the CSS files, giving me a very long HTML code.

https://www.tiroconarco.link/

I generate the files with a yarn generate, I suppose that I must put something in the configuration files so that it compresses the CSS.

Can you help me?

Thanks

Upvotes: 1

Views: 2375

Answers (1)

Nicolas Pennec
Nicolas Pennec

Reputation: 7631

Your CSS contents are already compressed by the Nuxt build process. But stylesheets are inlined in your HTML page for performance purpose, to avoid loading another CSS file.

(see default optimization options)

You can extract all your CSS to an external single file by configuration as below:

// nuxt.config.js

export default {
  build: {
    extractCSS: true
  }
}

See more about extractCSS on docs: https://nuxtjs.org/docs/configuration-glossary/configuration-build/#extractcss

Upvotes: 3

Related Questions