When using nuxt generate
I am generating various HTML pages that happen to be about 300 kB in size. Majority of the file is CSS style placed inline to it. Is it a way to put it in an external file and reduce size of HTML ?
Note: Nuxt has applied PostCSS Preset Env . By default it enables Stage 2 features and Autoprefixer , you can use build. postcss.
Nuxt 3 will support bundling with both the latest version of Webpack (version 5) as well as Vite for both development and production builds. Whichever one you choose, you'll be sure to experience a faster development experience and decreased production build times.
Usage. Nuxt allows to customize the babel configuration for the build. But this does not take module files or nuxt. config.
You can extract the CSS in the main chunk into a separate CSS file using
nuxt.config.js
module.exports = {
build: {
extractCSS: true
}
}
This is documented here
If you want to import css files globally use
module.exports = {
css: [
// Load a Node.js module directly (here it's a Sass file)
'bulma',
// CSS file in the project
'@/assets/css/main.css',
// SCSS file in the project
'@/assets/css/main.scss'
]
}
as documented here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With