DEV Community


How to add a global SCSS file to your Gridsome project

jordienr profile image Jordi Enric ・1 min read

I love Gridsome for it's easy setup, themes and over all developer experience. One thing I decided to do as soon as I set up my project was to add a global SCSS/SASS file for my global styles. This was I did not have to write global styles on my components which is not optimal if you want to keep a good separation of concerns. Here's how to do it:

Tell gridsome to load your scss in gridsome.config.js

Go to your gridsome.config.js file and write this:

module.exports = {
  css: {
    loaderOptions: {
      scss: {
        prependData: '@import "./src/assets/style/index.scss";'


In case you are using sass instead of scss remember to change "scss" to "sass" below loaderOptions.

Restart your server and that's it, you will be able to write use your scss variables in your components.

Have a good day ✌✌

Follow me on Twitter or find more articles in


Editor guide