quasar icon indicating copy to clipboard operation
quasar copied to clipboard

Make Sass/SCSS Variables available throughout the application when using Vue CLI

Open papotte opened this issue 6 years ago • 5 comments

Is your feature request related to a problem? Please describe. When using Quasar CLI, quasar SCSS/SASS variables can be used throughout the application. This issue tracks these changes. However, this does not work when using the Vue CLI as stated in the docs

Describe the solution you'd like I would like for the behaviour of SCSS/SASS Variables to be the same for Vue CLI and Quasar CLI

papotte avatar Feb 26 '20 19:02 papotte

@papotte I’m aware that it’s not directly the solution you requested (which I also would love to see in Quasar) – but maybe it helps you in some other way.

We use node-sass and sass-loader to import a _utilities.scss into every Vue component in our app to have our SCSS functions/mixins/variables etc. available in the <style> section of our Vue components.

In vue.config.js:

module.exports = {
  css: {
    loaderOptions: {
      sass: {
        prependData: `@import "@/styles/_utilities.scss";`
      }
    }
  }
}

Detailed info about this can be found in this article from Sarah Drasner on CSS Tricks: https://css-tricks.com/how-to-import-a-sass-file-into-every-vue-component-in-an-app/

matthiasmoier avatar Mar 01 '20 15:03 matthiasmoier

@papotte Quasar has no control over the Vue CLI... The simplest way is to use a loader as @matthiasmoier suggests

hawkeye64 avatar Mar 01 '20 22:03 hawkeye64

I just thought that maybe it could be possible to create a _quasar_variables.scss which contains all the variables from the Quasar Stylus files during the build process (or whenever it makes sense)… and then import it using the before mentioned loader approach (not necessarily automatically as probably not everybody would need it).

Just an idea and not thought through in detail, but maybe this could be used as way to make the variables accessible in SCSS in the components. (Which would be great.)

matthiasmoier avatar Mar 01 '20 22:03 matthiasmoier

@matthiasmoier This is one of the reasons why Quasar CLI was created. Then we wouldn't have to reply on other CLIs to do things for us.

hawkeye64 avatar Mar 01 '20 23:03 hawkeye64

@matthiasmoier this works perfectly. I think we could close this topic? Eventually the solution would be to just add this suggestion to the documentation.

papotte avatar Mar 02 '20 11:03 papotte