Comments (14)
@netstuff Try @epegzz/sass-vars-loader
instead of sass-vars-loader
:)
from sass-vars-loader.
Nice plugin 👍
Since this might be helpful to other people, the right way to configure this with Vue CLI (v3.8.4) is:
// vue.config.js
module.exports = {
chainWebpack: config => {
const moduleTypes = ['vue-modules', 'vue', 'normal-modules', 'normal']
moduleTypes.forEach(type =>
config.module
.rule('scss')
.oneOf(type)
.use('@epegzz/sass-vars-loader')
.loader('@epegzz/sass-vars-loader')
.options({
syntax: 'scss',
files: [path.resolve(__dirname, './src/styles/colors.js')],
})
)
},
}
I would also consider adding this to the documentation 🙂
from sass-vars-loader.
or inside of <style> use @import '~@/assets/styles/stylesmyfile.scss'
instead of a relative import - might fix the problem too
from sass-vars-loader.
@epegzz , thank u very much! I feel ashamed :(
from sass-vars-loader.
Haha, no worries! 😄
from sass-vars-loader.
Thanks @franciscolourenco! I opened #33. The documentation could use some general refresh anyways :) 👍
from sass-vars-loader.
Thanks @franciscolourenco! All works, but I don't understand how should I use it :(
I see that the my variables.json
file is loaded, because I saw SCSS-compiler errors on starts when it has errors. But when variables.json
is cleaned from errors I try to use some of it's variables in other file: variables.scss
and got an error: Undefined variable: "$fontRem"
.
variables.json
{
"fontRem": 14,
"gridColumns": 12,
"gutterSize": 8
}
and variables.scss
/* Global variables. */
$gridColumns: 16;
$defaultRem: $fontRem;
Please, help me to find proper way to use this plugin.
Thank you.
from sass-vars-loader.
@netstuff would need to see your vue.config.js
from sass-vars-loader.
@netstuff would need to see your vue.config.js
I found out that variables.json
already working in Vue one-file components! Yo!
But the problem steel remains for *.scss
files.
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')],
})
)
},
css: {
loaderOptions: {
sass: {
data: `
@import '~@/assets/styles/global';
@import '~@/assets/fonts/uikit/style.css';
`,
},
},
},
}
from sass-vars-loader.
I have not much knowledge about vue (in fact none at all 😄) but my suspicion would be, that the sass files are processed before the @epegzz/sass-vars-loader
is run.
from sass-vars-loader.
@netstuff how are you importing the *.scss
file you are having problems with?
from sass-vars-loader.
@netstuff how are you importing the
*.scss
file you are having problems with?
Using @import
directive within <style lang="scss">
section of a component.
from sass-vars-loader.
You might need import them in the <script> of js file with import '@/styles/myfile.scss'
from sass-vars-loader.
or inside of <style> use
@import '~@/assets/styles/stylesmyfile.scss'
instead of a relative import - might fix the problem too
It works! @franciscolourenco, thank u very much!
from sass-vars-loader.
Related Issues (20)
- Respect file order HOT 1
- Variable not getting to scss with web pack 3.11 in angular 5 HOT 5
- Typescript support HOT 1
- Leading zero in string gets removed HOT 14
- Missing dependencies in 4.1.0 HOT 1
- Broken as of version 4.3.0 HOT 6
- Can I use this for stylus or less ? HOT 2
- Improve documentation
- HRM doesn't work for variable files in symlinks or packages HOT 3
- Missing additional loader? Any help? HOT 1
- Variables undefined when use sass-loader.options.data attribute HOT 19
- Assertion error on precommit hook HOT 3
- SyntaxError: Unexpected token ']', web pack HOT 3
- Color names in JSON keys are interpreted as color objects by SASS HOT 4
- Unable to pass version string to add inside css comment HOT 2
- Is it possible to load the JSON file using inline loaders? HOT 1
- Passing transformer function as option HOT 3
- SassError: Invalid CSS after "..., -apple-system": expected ":", was ", BlinkMacSystemFon" HOT 1
- Webpack 5 implimentation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sass-vars-loader.