Skip to content
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

css not being loaded #52

Closed
uriklar opened this issue Jul 29, 2019 · 8 comments
Closed

css not being loaded #52

uriklar opened this issue Jul 29, 2019 · 8 comments

Comments

@uriklar
Copy link

uriklar commented Jul 29, 2019

Hi @jaebradley ,
Thanks for the example! I'm trying to get my component lib to work with rollup and sass without success.
I cloned your repo, ran the build, and imported in a CRA I created and you css for the an-example class isn't being loaded in my app. Which is the exact same issue I'm having with my lib...

Do you know what i'm doing wrong? Have you tried actually consuming these example components in an app and can verify the css get's injected?

Many thanks!
Uri

@jaebradley
Copy link
Owner

jaebradley commented Jul 29, 2019

Hey @uriklar, thanks for reaching out!

Have you tried actually consuming these example components in an app and can verify the css get's injected?

You can see the example components and CSS being utilized here: https://stackblitz.com/edit/example-rollup-react-component-npm-package?file=package.json

image

It'd be great to get some more background into what issues you're seeing.

@uriklar
Copy link
Author

uriklar commented Jul 30, 2019

Hi @jaebradley. Thanks for the ultra quick response :-)
It was my mistake. I wasn't aware I need to import the css separately.

@uriklar uriklar closed this as completed Jul 30, 2019
@jaebradley
Copy link
Owner

@uriklar no worries - it's not particular clear from the README that the CSS is built / imported separately. I'm hoping to add some more documentation in the future.

Cheers!

@uriklar
Copy link
Author

uriklar commented Jul 30, 2019

While we're here.. I was wondering if during your research you've found a good resource on building a tree shakable component library with Rollup (or even Webpack)?
I'm trying to achieve that and though i've marked "sideEffects": false it seams like my consumer app is getting the whole bundle regardless of what i'm importing.
Thanks again for the response and for the great example!

@jaebradley
Copy link
Owner

@uriklar are you tree-shaking ES6 modules only? Or are you transpiling ES6 modules into CommonJS?

@uriklar
Copy link
Author

uriklar commented Jul 30, 2019

The latter, transpiling to common js too

@jaebradley
Copy link
Owner

I think you need to tell Babel not to transpile ES6 modules so you can take advantage of static analysis.

image

https://developers.google.com/web/fundamentals/performance/optimizing-javascript/tree-shaking/

I could definitely be missing the ball on something as I don't know exactly what your setup is.

@uriklar
Copy link
Author

uriklar commented Jul 30, 2019

Thanks a lot! I'll try it out

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

No branches or pull requests

2 participants