postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables
MIT License
419 stars 35 forks source link

webpack live reload working? #37

Closed jschr closed 8 years ago

jschr commented 8 years ago

Has anyone got webpack live reload working with postcss-simple-vars?

Looks like it should work according to https://github.com/postcss/postcss-simple-vars/issues/8 but I can't seem to get it going. Changes made to variables.js aren't reflected until I restart webpack dev server.

My webpack config file looks like:

module: {
  loaders: [
    ...
    { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader') }
  ]
},

postcss: () => [
  require('postcss-discard-comments'),
  require('postcss-simple-vars')({ variables: () => require('./src/theme/variables') }),
  require('postcss-calc'),
  require('postcss-nested'),
  require('autoprefixer')
]
duncanbeevers commented 8 years ago

@jschr I'm seeing the same thing. I also tried replacing require with an equivalent require-nocache invocation and saw no change reflected in the browser.

chrishoage commented 8 years ago

I was only able to get it to work under the following conditions: 1) All files must be required separately that included in a flat manner. 2) require-nocache be used to import all of the files. 3) A file using the variable must be saved (even if nothing has changed) in order for the variable change to be picked up.

ai commented 8 years ago

Sorry, this question for webpack users. I didn’t use it.