bline / jade-html-loader

webpack loader for jade to html
MIT License
30 stars 27 forks source link

Css modules #18

Open glebmachine opened 8 years ago

glebmachine commented 8 years ago

Hi!)

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

dwayne commented 8 years ago

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

glebmachine commented 8 years ago

CSS modules export object like:

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

All css selectors become local without BEM.

dwayne commented 8 years ago

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

glebmachine commented 8 years ago

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

dwayne commented 8 years ago

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.

glebmachine commented 8 years ago

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)