cssinjs / jss-loader

JSS Loader for Webpack
MIT License
65 stars 8 forks source link

Loaders are unavailable within JSS #2

Open markdalgleish opened 8 years ago

markdalgleish commented 8 years ago

The most obvious example of this problem is that compilation fails if your JSS depends on another JSS file (e.g. when using CSS Modules' composes).

This is a critical issue that is likely to cause this project to become deprecated in favour of a Webpack plugin, along the lines of @andreypopp's Styling.

geekyme commented 8 years ago

I don't think we are also able to import vendor stylesheets like bootstrap from within a JSS right? That seems like a deal breaker.

kof commented 8 years ago

@markdalgleish not sure what you mean .... maybe an example can help ....

joshgillies commented 8 years ago

Correct me if I'm wrong but I think what @markdalgleish is referring to is currently the loader lacks the ability to pass compose statements back into Webpacks loader pipeline.

As an example:

colour.jss.js

module.exports = {
  '.blue': {
    color: 'blue'
  },
  '.green': {
    color: 'green'
  }
};

component.jss.js

module.exports = {
  '.hello': {
    composes: 'blue from "./colour.jss.js"'
  },
  '.world': {
    composes: 'green from "./colour.jss.js"'
  }
};

component.js

var styles = require('css?modules!jss!./component.jss.js');

var html = '<div class="' + styles.hello + '">Hello World!</div>';
joshgillies commented 8 years ago

Hrmm, actually the above statement isn't correct. composes seems to work exactly as expected in the above case. @markdalgleish when you get a moment care to chime in with regards to this issue?