My thinking around this was that inside the global.scss, it would only really import variables and mixins / placeholders - basically anything that the scoped components might need to reference or need access to.
You could probably also just list those files in the config, instead of creating a global.scss file - I just preferred it that way.
You bring up a good point, I think a good way of tackling this would be to have just variables and things that your components need to reference in the vue config file, and then any other 'global' styles such as basic html / body / normalize files could be imported into your layout / wrapper vue file.
I created an import.scss for all my variables and mixins / placeholders used with the style-resources-loader plugin, and imported the global css part with a simple import in my main.js file.
I think it give the best of both worlds if you want to write style scoped and also use some general (unscoped) style like a reset, normalize, general UI, etc.
Great! Yeah that is always the case for me, I always have sort of base styles that apply globally, but I want to scope all my components. So doing it this way works perfectly :)
Hi Emmanuel, the import.scss file should just have things like variables and mixins that the other files will need access to. If you don't use the plugin to serve the variables etc, you can't access them and use them within other components.
Hey Allan, great question!
My thinking around this was that inside the global.scss, it would only really import variables and mixins / placeholders - basically anything that the scoped components might need to reference or need access to.
You could probably also just list those files in the config, instead of creating a global.scss file - I just preferred it that way.
You bring up a good point, I think a good way of tackling this would be to have just variables and things that your components need to reference in the vue config file, and then any other 'global' styles such as basic html / body / normalize files could be imported into your layout / wrapper vue file.
What do you think?
Yes, I ended up with this solution so far :).
I created an
import.scss
for all my variables and mixins / placeholders used with thestyle-resources-loader
plugin, and imported the global css part with a simple import in my main.js file.I think it give the best of both worlds if you want to write style scoped and also use some general (unscoped) style like a reset, normalize, general UI, etc.
Great! Yeah that is always the case for me, I always have sort of base styles that apply globally, but I want to scope all my components. So doing it this way works perfectly :)
Hey Allan and Lynne, Sorry, kinda lost here :) Can you explain what you did to solve this? Especially with the
import.scss
fileAlthough, I think maybe importing the
global.scss
file inApp.vue
might also be a good solution?Hi Emmanuel, the import.scss file should just have things like variables and mixins that the other files will need access to. If you don't use the plugin to serve the variables etc, you can't access them and use them within other components.
So basically, from your example. Everything imported in the
global.scss
file is available to use in all the components?Awesome post Lynne. This helped me clean up way too many double imports.
Emmanuel, I was a little confused too.
For the stylesheet that you call into
vue.config.js
only importmixins
andvariables
(no style selectors/rules).Call other
global.scss
(declared rules and stuff) elsewhere, likemain.js
or a parent app likeApp.vue
.Any style rules imported to a stylesheet through
vue.config.js
will import again for each component that uses it.