jade-html-loader icon indicating copy to clipboard operation
jade-html-loader copied to clipboard

Css modules

Open glebmachine opened this issue 9 years ago • 6 comments

Hi!)

Can you add css-modules support please. https://github.com/css-modules/css-modules fr: https://github.com/css-modules/webpack-demo

glebmachine avatar Mar 09 '16 20:03 glebmachine

@glebmachine What does CSS modules have to do with Jade?

dwayne avatar Mar 30 '16 14:03 dwayne

CSS modules export object like:

{
  .className: unique_hash_for_this_classname1,
  .className2: unique_hash_for_this_classname2,
}

All css selectors become local without BEM.

glebmachine avatar Mar 30 '16 16:03 glebmachine

Okay. So do you want the template function to be called with this object (the locals) that CSS modules exports?

dwayne avatar Mar 30 '16 22:03 dwayne

Hm, is it possible to use require function right into template, like in the jade-loader or plain node js?

glebmachine avatar Mar 31 '16 05:03 glebmachine

From my understanding, jade-loader will return the template function for you. That template function takes a locals object that it uses to substitute into the template when executed. Maybe try using that. See here.

dwayne avatar Mar 31 '16 08:03 dwayne

Yes, they provide global variables into template scope, so, require become available from template scope.

var css = require('style.css')
div(class=css.className1)
vid(class=css.className2)

glebmachine avatar Mar 31 '16 11:03 glebmachine