okonet / rework-loader

Loader for webpack which uses Rework (https://github.com/reworkcss/rework) post-processor for CSS
MIT License
2 stars 1 forks source link

Does this module work with @import ? #2

Closed remoe closed 9 years ago

remoe commented 9 years ago

When I try to use something like that:

var rework_custom_media = require('rework-custom-media');
var rework_vars = require('rework-vars');
...
      { test: /\.css$/, loader: "style-loader!css-loader!rework-loader!autoprefixer-loader?browsers=last 2 version" },
...
rework: {
    use: [ rework_vars(), rework_custom_media()]
  },

and the css file has something like that:

@import '~basscss/css/basscss.css';

It doesn't work with vars that are created in basscss.css. Do you have a working sample of it?

okonet commented 9 years ago

This module is just a wrapper for rework. It does post-processing as it would be done in node.js. Please try if it works with the plain node.js setup.

Just to make it clear: the file ~basscss/css/basscss.css exist and served by webpack without any error, right?

remoe commented 9 years ago

yes, it has no errors. I used the latest WebPack. But the CSS content that goes through your rework plugin has not resolved @imports in it. The imports should be resolved with WebPack module system. I think your plugin works only with a completely resolved CSS without any @imports, right?

okonet commented 9 years ago

Yes, that's true. I think the css-loader resolves the @imports but it's too late obviously...

okonet commented 9 years ago

And what if you change the order of the css-loader and rework-loader in your config?

okonet commented 9 years ago

This also looks like your case: https://github.com/webpack/css-loader#importing-and-chained-loaders

remoe commented 9 years ago

thanks, but I've tried this also and has no luck with rework. I didn't found a solution with rework-vars and I was switched temporary to atomify. But I'm really interested in a solution with webPack.

okonet commented 9 years ago

Please check this loader out: https://github.com/aaronj1335/rework-webpack-loader

I think it should solve you problem.

remoe commented 9 years ago

thanks for your info! I've also tried this, but this does also not worked on my setup. But I try it on a simpler setup to find out what the problem is.