css-modules / css-modules-require-hook

A require hook to compile CSS Modules in runtime
MIT License
484 stars 44 forks source link

css-loader patterns #41

Closed mightyaleksey closed 9 years ago

mightyaleksey commented 9 years ago

Since many ppl use the require hook together with webpack, I think we can make the simplier API for the require hook and provide opportunity to specify the same patterns as for the css-loader. So the user will be able to provide the string pattern for the generateScopedName option:

hook({
  generateScopedName: '[name]__[local]___[hash:base64:5]'
})

I'm going to make another module (What will be the name?) which will implement that. It will be possible to use it with css-modulesify also, so we will get the similar API in our tools. Module will use interpolatename function and solve the problem with the [local] pattern. Smthing like:

/**
 * @param  {string} name     Usually a class name
 * @param  {string} filepath
 * @return {string}
 */
function generate(name, filepath) {
  // return the new name
}

Also I will same the opportunity to provide custom functions.

https://github.com/css-modules/postcss-modules-scope/blob/master/src/index.js#L38 https://github.com/webpack/css-loader/blob/master/lib/processCss.js#L148-L150 https://github.com/webpack/css-loader/blob/master/lib/getLocalIdent.js

mightyaleksey commented 9 years ago

I've published it in a beta version: https://github.com/css-modules/css-modules-require-hook/releases/tag/2.0.0-beta2

So you may try to use it.

mightyaleksey commented 9 years ago

Okay, published it: https://github.com/css-modules/css-modules-require-hook/releases/tag/2.0.0