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

Does not work with NextJS due to Next not supporting global CSS files #383

Closed
UlyssesInvictus opened this issue Feb 10, 2021 · 3 comments
Closed

Comments

@UlyssesInvictus
Copy link

UlyssesInvictus commented Feb 10, 2021

The current installation for this library recommends direct import of the styles library as a global CSS file.

However, some frameworks like NextJS forbid this methodology, throwing the following error:

Global CSS cannot be imported from within node_modules.
Read more: https://err.sh/next.js/css-npm

(More about this practice in NextJS can be found in this thread).

Is it possible to update the library so that style is automatically injected into the component? I understand why the styles are exported separately (to support themes), but in our case we cannot use the recommended solution of manually exporting the library styles from _app.js.

In my project's particular case, we are resorting to manually copying the styles from this lib and injecting them in our project location, but this is not ideal, so alternate solutions would be helpful. Thank you!

@bl00mber
Copy link
Owner

bl00mber commented Feb 10, 2021

This practice introduced by NextJS seems like a regression from existing JS standard functionality.
As previous user of NextJS, I remember that it allowed previously to import CSS files at least in older versions.
If it currently forbids importing of CSS modules from NPM folder, I can suggest to use older NextJS versions, move CSS file to another folder, or use examples from the issue in your link.
Initially styles were separated from the lib to support NextJS which produced numerous bugs when used with inline styles.

@gabrielalmeida
Copy link

What version of NextJS are you using? This should be supported in recent versions, It works for me importing on _app or inside any component directly. Check if you're above v9.5.4.

Note that this NextJS feature is broken when using npm link, maybe that's your case.

@UlyssesInvictus
Copy link
Author

UlyssesInvictus commented Feb 11, 2021 via email

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

3 participants