H
H
hadaev_ivan2016-02-10 19:23:00
JavaScript
hadaev_ivan, 2016-02-10 19:23:00

Webpack how to pass variable to scss?

I use webpack.

module: {
    loaders: [
      { test: /\.scss$/, loader: ExtractTextPlugin.extract("style", "style!css?-minimize!sass?sourceMap")},
      { test: /\.jsx?$/, loader: 'jsx-loader?harmony' } 
    ]
  },

Depending on the environment (prod / dev), you need to transfer the value of the variables to scss, I could not find anything working. Tried to use one of these https://github.com/jtangelder/sass-loader/issues/49
didn't work. Any thoughts on this? Thank you)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Matyukha, 2016-02-14
@Frontier

You can create 2 files with variables, put EnvironmentPlugin and import one or another file depending on the environment.
For example:

var vars = (NODE_ENV == 'prod') ? 'prod_vars' : 'dev_vars';  
....
stylus: {
        import: [' __dirname + '/commons/' + vars+'.styl', ']
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question