DEV Community

Jordi
Jordi

Posted on • Edited on

5 1

How to add a global SCSS file to your Gridsome project

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";'
      }
    }
  }

}
Enter fullscreen mode Exit fullscreen mode

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 ✌✌

Find me on Twitter

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more