-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
Does not bundle all imported css files #102
Comments
Even when I remove the codesplitting it still does not work. |
@danez thanks for issue, in near future i will investigate |
Noticing this too. No styles from external packages appear in the bundled css. |
I am having the same issue. If you find the solution, could you please update. Thanks a lot. |
Looks like a bug, feel free to investigate and fix PR |
I've investigated it further and the issue seems to appear when using |
react-live has Instead the package.json should do You can also override this in your module.rules: |
Looks like all the packages I tested with scoped names have ‘sideEffects: false’ in their package.json. The ones without scope don’t. So my conclusion above is invalid - thank you for the clarification sokra. I think this issue can be closed. Out of curiousity: why does ‘require’ work in this case? Do using it imply that you desire side effects? |
@sokra Appreciated that this advice represents the status quo, but I would like to bring up (prev) that ideally the developer shouldn't have to specify this in their |
@sokra you are a legend! Fixed this exact issue for me. Wish I had read your comment an hour ago :) |
@sokra The behavior here is quite problematic for libraries that wish to support tree shaking unused CSS. Imagine a package with multiple components. Importing one of the components should include only the CSS for that component, not the entire package. import {Button} from 'my-great-button'; my-great-button has an index.js file with the following: export * from './Button';
export * from './FancyButton'; Importing Button should not include the CSS for FancyButton as well, but with CSS should only be included if the JS that imports it is included. i.e. if FancyButton is tree-shaken, so should whatever CSS FancyButton imports. I wouldn't necessarily think of CSS itself as a side effect: the effect is really in the module that imports the CSS. |
Answer above #102 (comment) |
I have a weird problem:
I have a js file that imports a css file and a less file. The imported less file is included in the extracted file the imported css file is not.
Now I think this might have todo because I recently added code splitting here: https://github.com/reactjs/react-tabs/blob/master/examples/src/components/ExampleItem.js#L19 But this async import and the import of the css should not influence each other as far as I understand.
The output of webpack looks like this, which does not really help me:
Webpack config: https://github.com/reactjs/react-tabs/blob/master/webpack.config.js
How to reproduce:
react-live/react-live.css
(easily discoverable by searching for.prism-code {
which should be included)The text was updated successfully, but these errors were encountered: