Code Monkey home page Code Monkey logo

Comments (14)

epegzz avatar epegzz commented on July 23, 2024 1

@netstuff Try @epegzz/sass-vars-loader instead of sass-vars-loader :)

from sass-vars-loader.

franciscolourenco avatar franciscolourenco commented on July 23, 2024 1

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.

franciscolourenco avatar franciscolourenco commented on July 23, 2024 1

or inside of <style> use @import '~@/assets/styles/stylesmyfile.scss' instead of a relative import - might fix the problem too

from sass-vars-loader.

netstuff avatar netstuff commented on July 23, 2024

@epegzz , thank u very much! I feel ashamed :(

from sass-vars-loader.

epegzz avatar epegzz commented on July 23, 2024

Haha, no worries! 😄

from sass-vars-loader.

epegzz avatar epegzz commented on July 23, 2024

Thanks @franciscolourenco! I opened #33. The documentation could use some general refresh anyways :) 👍

from sass-vars-loader.

netstuff avatar netstuff commented on July 23, 2024

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.

franciscolourenco avatar franciscolourenco commented on July 23, 2024

@netstuff would need to see your vue.config.js

from sass-vars-loader.

netstuff avatar netstuff commented on July 23, 2024

@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.

epegzz avatar epegzz commented on July 23, 2024

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.

franciscolourenco avatar franciscolourenco commented on July 23, 2024

@netstuff how are you importing the *.scss file you are having problems with?

from sass-vars-loader.

netstuff avatar netstuff commented on July 23, 2024

@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.

franciscolourenco avatar franciscolourenco commented on July 23, 2024

You might need import them in the <script> of js file with import '@/styles/myfile.scss'

from sass-vars-loader.

netstuff avatar netstuff commented on July 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.