duojs / duo

A next-generation package manager for the front-end
3.42k stars 118 forks source link

Local scope css #471

Closed ismay closed 9 years ago

ismay commented 9 years ago

I recently discovered that webpack's css-loader allows you to write css in a local scope: the end of global css (repo here: https://github.com/webpack/css-loader#local-scope)

Now I prefer using duo, and was wondering whether this kind of functionality would fit within duo, and if so, how? I think it would be a great thing for duo to support.

matthewmueller commented 9 years ago

Haha, yah I was just reading about this. Definitely seems like a step forward. I doubt I'll have the time to implement this, but I'm accepting PRs!

dominicbarnes commented 9 years ago

Is there any reason this can't be a plugin? (I haven't read that readme in-depth)

matthewmueller commented 9 years ago

Definitely could, and should. Here's the one I would use: https://github.com/css-modules/postcss-modules-local-by-default. The duo plugin would basically do what css-loader is doing in webpack.

ismay commented 9 years ago

I might be misunderstanding, but I believe that plugin was just created to make local scope css the default for css-loader. It converted all css to local scope by default, and required you to opt out with a :global keyword (instead of opt-in with :local):

What if — instead of requiring a special syntax — our selectors were local by default, and global selectors were the opt-in exception?

It still required css-loader for the local css magic. Also it's been deprecated, since it has been merged into css-loader:

The original ideas presented in postcss-local-scope have been accepted into Webpack by Tobias Koppers, meaning that the project is now deprecated.

So it would probably be necessary to create a plugin from scratch for local scope css (or use what can be used from css-loader). I completely agree that this should be a plugin btw.

dominicbarnes commented 9 years ago

I'm going to close this issues, as it's not a problem duo itself is going to solve. If you have any trouble creating a plugin, feel free to reach back out to us.

ismay commented 9 years ago

I'm pretty busy right now, so I wont be having time to create the plugin anytime soon. But should there be any issues if and when I can find the time I'll let you know. Thanks!