Vue-cli: How to use globals variables in sass?

Created on 31 Jan 2018  路  2Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

How to use globals variables in sass - vue 2.5.13 / generate on vue/cli-service 3.0.0-alpha.5

What does the proposed API look like?

Use globals variables in sass - vue 2.5.13 / generate on vue/cli-service 3.0.0-alpha.5

Most helpful comment

We will have dedicated documentation for this use case.

In brief, this is what you need:

// vue.config.js
module.exports = {
  css: {
    loaderOptions: {
      sass: {
        data: fs.readFileSync('./src/variables.scss', 'utf-8')
      }
    }
  }
}

All 2 comments

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server, gitter or StackOverflow.


The answer you're looking for is at https://vue-loader.vuejs.org/en/configurations/pre-processors.html 馃檪

We will have dedicated documentation for this use case.

In brief, this is what you need:

// vue.config.js
module.exports = {
  css: {
    loaderOptions: {
      sass: {
        data: fs.readFileSync('./src/variables.scss', 'utf-8')
      }
    }
  }
}
Was this page helpful?
0 / 5 - 0 ratings