question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading a global scss mixin / variable file in version 3

See original GitHub issue

Hi

How does one achieve this - Loading a global settings file

{
  loader: 'sass-resources-loader',
  options: {
    resources: path.resolve(__dirname, '../src/style/_variables.scss')
  }
}

using vue-cli 3.0.0-beta.6?

From information in the readme, I thought something like this in vue.config.js:

css: {
  loaderOptions: {
    sass :
    {
      loader: 'sass-resources-loader',
      options: {
        resources: path.resolve(__dirname, 'src/scss/_variables.scss'),
      },
    },
  }
}

will do the trick. But I’m getting an error if I try to use a a variable (e.g. $primary) in a component:

color: $primary;
      ^
  Undefined variable: "$primary".
  in /src/App.vue (line 23, column 12)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:13

github_iconTop GitHub Comments

10reactions
bbughcommented, May 5, 2018

Note that this preprocessor-loader is not hot reloaded. You’ll have to shut down and restart the server if you make changes to see them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import Sass/SCSS mixins global? - DEV Community ‍ ‍
I import the two .scss files in the App.js so I can access the classes/mixins/variables global. But only the classes are accessible.
Read more >
How to use a SASS $variable across multiple pages using ...
Hello Guys!! · 1. Have a index or main file where all your variables are declared in just like this (for me, my...
Read more >
Vue 3 - setting up global Sass/SCSS variables - WebDevEtc
It is very easy to get Vue 3 set up with SCSS/Sass. I found it a bit of a pain to find instructions...
Read more >
SASS | Use variables across multiple files - GeeksforGeeks
To use variables across multiple files in SASS is carried out by @import rule of SASS. @import rule which import Sass and CSS...
Read more >
Globally Load SASS into your Vue.js Applications
As a project grows up, you start separating your SASS variables, mixins and functions in separate files. You can import them by using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found