css-modules / css-modules-require-hook

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

Cannot both control generateScopedName and use posstcss plugins. #37

Closed pekim closed 9 years ago

pekim commented 9 years ago

The return in https://github.com/css-modules/css-modules-require-hook/blob/master/src/index.js#L58 means that the generateScopedName option is ignored when postcss plugins are configured (with use).

It looks like https://github.com/css-modules/css-modules-require-hook/pull/34 was intended to address this, but as far as I can tell it doesn't. The return statement continues to be a problem.

Replacing

  if (customPlugins) {
    return void (plugins = customPlugins);
  }

  plugins = [];

with

  if (customPlugins) {
    plugins = customPlugins;
  } else {
    plugins = [];
  }

(or at least hacking in the equivalent in dist) works for me. I'm not sure if it would break any other use cases.

I have a feeling that I may be simply overlooking or misunderstanding something.

mightyaleksey commented 9 years ago

Hi, can you show your set up or at least describe how you want to use it?

generateScopedName function usually passed to the scope plugin. That's why it will not work if you specify the custom list of plugins with use.

pekim commented 9 years ago

There was nothing in the scope plugin's documentation about how to configure the {{generateScopedName}}, so I didn't go that route.

Now that I've looked at the plugin's source, I see that it is simply an option that can be passed. So I'll do that.

I shouldn't have been quite so lazy in the first place. Sorry for the noise.

mightyaleksey commented 9 years ago

It's ok, I guess I'd better update the readme file :)

Thank you for your concern