How can I convert inline-CSS to CSS-files in nuxt.js? I have both scoped styles and global scss file in my app. I have already tried below code but no luck.
build: {
optimization: {
splitChunks: {
chunks: 'all',
automaticNameDelimiter: '.',
name: 'rameez',
cacheGroups: {}
}
},
optimizeCSS:true
}
here you can see all the CSS including my global.scss is shown as an inline style.
Now about you doubt if you want to import the CSS as globally, the correct place is inside your nuxt. config. js, inside this file, you have a property called head, and inside the head we will configure all the imports. So, inside nuxt.
CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.
Inline Style Syntax The style attribute is just like any other HTML attribute. It goes inside the element's beginning tag, right after the tag name. The attribute starts with style , followed by an equals sign, = , and then finally uses double quotes, "" , which contain the value of the attribute.
Ultimately, it's important in terms of inlining CSS and performance that you don't just dump all the CSS for your site into the head. If you inline too much, the performance implications will be worse than what you started with.
You are looking for extractCss property i think
build:{
extractCSS: true
}
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