Skip to content

Instantly share code, notes, and snippets.

@bikubi
Last active April 10, 2019 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bikubi/76325574c7c8236d5f14323d52e472ab to your computer and use it in GitHub Desktop.
Save bikubi/76325574c7c8236d5f14323d52e472ab to your computer and use it in GitHub Desktop.
Use Quasar variables in SCSS stylesheets (incomplete)

Quasar supports SCSS but the style variables won't be available.
Here's a possible workaround -- incomplete & untested, since I gave up, went ahead and used stylus. (This is guide is primarily directed at future me, should this become more compelling in the future.)

Install stylus-converter

yarn add --dev stylus-converter

Create an ad-hoc Webpack plugin that runs the converter. My node foo isn't great, so I'll stick with npx.

// quasar.conf.js
module.exports = function (ctx) {
  return {
    // ...
    build: {
     // ...
      extendWebpack (cfg) {
         // ...
         cfg.plugins.push({
          apply: (compiler) => {
            compiler.hooks.beforeCompile.tap('AuslightScssizeStylVars', (compilation) => {
              const exec = require('child_process').exec
              exec('npx stylus-converter -i node_modules/quasar/src/css/variables.styl -o src/css/quasar.variables.default.scss')
              exec('npx stylus-converter -i src/css/quasar.variables.styl -o src/css/quasar.variables.local.scss')
            })
          }
        })

Import in component

// foo.vue
<style lang="scss">
  // really not sure about paths here
  @import 'quasar.variables.default'
  @import 'quasar.variables.local'
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment