-
Notifications
You must be signed in to change notification settings - Fork 85
Composing CSS Modules Results in Duplicate Output #55
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
Comments
You can do that with the As you'll read there, you have to do some extra work to make sure tools like babel-plugin-universal-import serve both the common chunk and the split chunk. |
Apologies, but the Furthermore, #47 doesn't seem to say anything about using CSS module composition, only imports. |
@mgreystone Were you able to resolve this issue? I'm having the same problem and it's not clear to me how to proceed. Thanks |
@jkettmann I'm afraid I have not been able to resolve this problem. I am no closer to a solution. Any advice is appreciated. |
@mgreystone Sorry, I misunderstood the issue actually. I thought this was about duplicated css in general, which I was able to solve. I didn't realize that this one is specific to using CSS |
Funny this issue is closed because it does not seem like it is solved and I'm facing the same issue. @mgreystone this works out of the box for me with Webpack 4 and https://github.com/webpack-contrib/mini-css-extract-plugin. With Webpack 3 and this plugin extract-css-chunks-webpack-plugin, I have a main bundle that imports base styles such as // main.css
@import `helpers/buttons.css' // main.js
import './main.css' then I would have an async component that imports CSS that implements .button {
composes: button from 'helpers/buttons.css';
// ..some more styles here // MyAsyncComp.js
import {button} from './MyAsyncComp.css' The result would be a duplication of the button class in both the |
Mini Css Extract Plugin is built by the webpack team, and though not fully complete in its feature-set, will be the go-to solution going forward. I think they're gonna integrate it further and give webpack itself first class css handling, code-splitting, etc. Like, you'll be able to dynamically So with that said, and given how close webpack now is, I likely won't find time to add anything to this repo. |
@faceyspacey I was just reverting back to Webpack 3 because having some perf issues and was trying to have the same experience with CSS code splitting. I'm using So, sounds like it's a moot point but thought I might as well document it here to help anyone else facing this issue. |
I am working with CSS modules & dynamic imports. When importing a CSS file that composes from another module, that code will be duplicated between different modules.
For example:
app.css
a.css
b.css
Builds to
main.bundle.css
a.bundle.css
b.bundle.css
As you can see, the results composed from app.css is included in all three bundles. Is there a way to combine this common code?
Full working example here
The text was updated successfully, but these errors were encountered: