jss-loader icon indicating copy to clipboard operation
jss-loader copied to clipboard

Loaders are unavailable within JSS

Open markdalgleish opened this issue 10 years ago • 4 comments

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.

markdalgleish avatar Sep 10 '15 22:09 markdalgleish

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.

geekyme avatar Sep 13 '15 17:09 geekyme

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

kof avatar Sep 29 '15 15:09 kof

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 avatar Dec 08 '15 06:12 joshgillies

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?

joshgillies avatar Dec 08 '15 21:12 joshgillies