GithubHelp home page GithubHelp logo

isabella232 / sass-vars-loader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from epegzz/sass-vars-loader

0.0 0.0 0.0 13 KB

A sass vars loader module for webpack. Supports JS or JSON files and plain JS objects.

License: MIT License

JavaScript 100.00%

sass-vars-loader's Introduction

A SASS vars loader for Webpack

Load global SASS vars from JS/JSON files or from Webpack config.

Install

npm install @epegzz/sass-vars-loader --save-dev

Usage with passing vars directly in webpack config

Simply pass the SASS vars as plain JS object to the sassVars config property:

// webpack.js
loader: ExtractTextPlugin.extract('style', 'css!sass!@epegzz/sass-vars-loader')
sassVars: {
  vars: {
    breakpoints: {
      small: '300px',
      medium: '600px'
    }
    colors: {
      error: 'red'; 
    }
  }
}

Usage with loading vars from JS or JSON files

Pass filenames as array to the sassVars config object:

// webpack.js
loader: ExtractTextPlugin.extract('style', 'css!sass!@epegzz/sass-vars-loader')
sassVars: {
  files: [
    path.resolve(__dirname, '/path/to/breakpoints.js'), // JS
    path.resolve(__dirname, '/path/to/colors.json'), // JSON
  ]
}

With breakpoints.js:

const breakpoints = {
  small: '300px',
  medium: '600px',
}
module.exports = { breakpoints };

And colors.json:

{
  "colors": {
    "error": "red"
  }  
}

This will result in the following SASS vars being available in all SASS files:

$breakpoints: (
  small: 300px,
  medium: 600px,
);

$colors: (
  error: red,
);

Acknowledgments

SASS var generator shamelessly copied from Kasu/jsonToSassVars.js

sass-vars-loader's People

Contributors

brandon-pereira avatar epegzz avatar flenter avatar gilbode avatar iamtheiam avatar termie avatar

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.