Roots Discourse

Sage 9 ~ Vue ~ Global Sass Variables/Imports in Webpack


I’m having trouble getting global sass variables with sass-loader to work properly. I combined the instructions here with pascallaliberte’s method of implementing vue-style-loader for CSS. So the rule is placed above the other test: /\.scss$/ and looks like this:

        test: /\.scss$/,
        exclude: config.paths.assets,
        use: [
          { loader: 'vue-style-loader' },
          { loader: 'css-loader' },
          { loader: 'sass-loader',
            options: {
              data: `@import "scripts/vue/Project/SCSS/test.scss";`

When I load a variable (or try to import a file) into test.scss, I’m still getting a build error ‘undefined variable’ when trying to use it in the single file component:

<style lang="scss">

The test: /\.css$/ rule from the above instructions is still present.

Any ideas?