Skip to content

Rebuild css modules with defined order #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Diokuz opened this issue Apr 12, 2018 · 13 comments
Open

Rebuild css modules with defined order #98

Diokuz opened this issue Apr 12, 2018 · 13 comments
Labels

Comments

@Diokuz
Copy link

Diokuz commented Apr 12, 2018

Hi there)

I wrote a-webpack-plugin which makes it possible to generate super short css classNames, like .a .b... .zz ...
My plugin works with ExtractTextPlugin, and it doesn't with mini-css-extract-plugin (

The problem is that when I rebuild css modules in a proper order, mini-css-extract-plugin
just drops all css files → no css output at all.

https://github.com/Diokuz/a-webpack-plugin/blob/master/index.js#L158

Any suggestions how to fix that?

My plugin's algorythm is very simple:

  1. Wait till all css modules are loaded by webpack
  2. Find them and sort
  3. Rebuild all css modules in a defined order, so build is deterministic (chunkhash and content is constant for particular git commit).

As I understood from your source, you use childCompiler in loader, which is reused in plugin part. But I still dont get it, why compilation.rebuildModule not working...

Thanks in advance)

@sokra
Copy link
Member

sokra commented Apr 12, 2018

mini-css-extract-plugin no longer uses rebuildMoulde internal, but this shouldn't a problem.

Technically your solution should also work with the mini-css-extract-plugin. I don't know why it doesn't work.

Does a very simple plugin works that just calls rebuildModule work? If not you can build a test case for the mini-css-extract-plugin from this and PR it. That would help.

@Diokuz
Copy link
Author

Diokuz commented Apr 12, 2018

Thanks! Will do that.

@Diokuz Diokuz closed this as completed Apr 12, 2018
@Diokuz
Copy link
Author

Diokuz commented Apr 12, 2018

Here we are: No css file with mini-css-extract-plugin demo

It works with ExtractTextPlugin@4 (ETP4 demo), but I cannot use it because of webpack-contrib/extract-text-webpack-plugin#767

@Diokuz Diokuz reopened this Apr 12, 2018
@Diokuz
Copy link
Author

Diokuz commented Apr 12, 2018

Actually webpack-contrib/extract-text-webpack-plugin#767 has the same symptoms

@Diokuz
Copy link
Author

Diokuz commented Apr 19, 2018

Any suggestions so far?)
Is it a bug, or should I use something else?

@alexander-akait
Copy link
Member

@Diokuz need fix this bug and send PR

@Diokuz
Copy link
Author

Diokuz commented Apr 28, 2018

Cool! So, it is a confirmed webpack4 bug and it will be fixed in near future?

@Diokuz
Copy link
Author

Diokuz commented Jun 4, 2018

@evilebottnawi @sokra any news on this issue?)

@alexander-akait
Copy link
Member

@Diokuz PR welcome

@Diokuz
Copy link
Author

Diokuz commented Jun 9, 2018

@evilebottnawi unfortunately I have no time to explore webpack code to find out why compilation.rebuildModule doesnt works properly in 4th version :(
No hope to fix that without me?

@alexander-akait
Copy link
Member

@Diokuz issue in my todo, but i have big todo 😄

@michael-ciniawsky michael-ciniawsky changed the title rebuild css modules with defined order Rebuild css modules with defined order Aug 24, 2018
@franklin-ross
Copy link

I think I have this same issue.

I'm issuing a rebuild of my CSS files in the finishModules hook so I can narrow down the set of files that Tailwind passes to it's JIT. The rebuild happens and I can eyeball the updated source in the debugger mid-build, but MiniCssExtractPlugin outputs the original module, not the rebuilt one. If I don't use MiniCssExtractPlugin, the CSS output updates fine.

@franklin-ross
Copy link

franklin-ross commented Oct 4, 2022

When I was debugging this, I noticed there are 2 very similar CSS modules (as in Webpack modules in the compilation) for each actual CSS file in the dependency tree. I don't know if this is relevant, but I wonder whether only one is updating or something?

I've carved them down to show the only differences I can find, which mostly seems to be in their dependencies. After the rebuild, the first one ends up with source of '// extracted by mini-css-extract-plugin\nexport {};' and the second ends up with the full and correctly rebuild source.:

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants