sass-vars-loader: Variables undefined when use sass-loader.options.data attribute
Hello! I use sass-vars-loader
with Vue Cli 3 and I try to move common scss-files to app config:
const path = require('path');
module.exports = {
chainWebpack: (config) => {
const moduleTypes = ['vue-modules', 'vue', 'normal-modules', 'normal'];
moduleTypes.forEach(moduleType =>
config.module
.rule('scss')
.oneOf(moduleType)
.use('@epegzz/sass-vars-loader')
.loader('@epegzz/sass-vars-loader')
.options({
syntax: 'scss',
files: [
path.resolve(__dirname, 'src/assets/styles/contracts/variables.json'),
path.resolve(__dirname, 'src/assets/styles/contracts/icons.json')
],
})
)
},
css: {
loaderOptions: {
sass: {
data: `
@import '~@/assets/styles/vars';
@import '~@/assets/styles/util';
@import '~@/assets/styles/func';
@import '~@/assets/styles/mixins';
@import '~@/assets/styles/colors';
`,
},
},
},
}
But on app loaded I have got an error: โUndefined variable: $paletteโ. It works properly, when I importing common scss-files directly, but I want to import it all in one place.
Can you help me?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 19 (10 by maintainers)
@dschox file order is now respected in
v6.0.0
. Thanks for your patience ๐oh yeah, absolutely ๐
The year is not over yet! ๐
@epegzz Any news on this? ๐
@epegzz I think a PR is out of my league ๐ Is it possible you can do this this year? ๐
Hm, this would actually not work, since the sass files always come first. Thatโs a stupid design! ๐ ๐
I could change that. Itโs basically #23