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

Nuxt's import protection triggers #811

Closed
manniL opened this issue Feb 23, 2024 · 5 comments
Closed

Nuxt's import protection triggers #811

manniL opened this issue Feb 23, 2024 · 5 comments

Comments

@manniL
Copy link
Contributor

manniL commented Feb 23, 2024

Version

@nuxtjs/tailwindcss: 6.11.4
nuxt: 3.10.2

Reproduction Link

https://stackblitz.com/edit/github-hoyhk3?file=tailwind.config.ts,package.json

Steps to reproduce

  1. Start the app
  2. See the import protection in the console

What is Expected?

No error

What is actually happening?

Nuxt's import protection is triggering

Workaround

Remove the content in the Tailwind Config, then restart the server.
This means that files from server/ are not imported and analyzed anymore, not triggering the protection.

Related

nuxt/nuxt#25534
nuxt/nuxt#25162

@manniL manniL added the bug Something isn't working label Feb 23, 2024
@ineshbose
Copy link
Collaborator

Would this mean that we include something like !${nuxt.options.serverDir}/**/*.ts in the content? This may cause side-effects; some devs may be adding in styles from server-side possibly?

Although the module would still be resolving the right content, while this seems to be the user-input causing the issue - so they would have to narrow the paths accordingly. What do you think?

@manniL
Copy link
Contributor Author

manniL commented Feb 24, 2024

Would this mean that we include something like !${nuxt.options.serverDir}/**/*.ts in the content? This may cause side-effects; some devs may be adding in styles from server-side possibly?

I never worked with negative globs in the tailwind config. Not sure 🤔
Ideally this could be solved differently as I think it is reasonable to check server-styles (e.g. when rendering HTML via serve routes).

(cc @danielroe @pi0 so you are aware)

@ineshbose
Copy link
Collaborator

The module doesn't automatically add the serverDir; the dev has added that explicitly in the configuration (being user input), so I would ask them to narrow the glob and/or add '!./src/server/**/*.ts' to their content array.

@ineshbose ineshbose removed bug Something isn't working pending labels Feb 28, 2024
@manniL
Copy link
Contributor Author

manniL commented Feb 29, 2024

@ineshbose but what if the server (route e.g.) returns tailwind classes? 🤔
I think this is still a valid use case

@ineshbose
Copy link
Collaborator

@ineshbose but what if the server (route e.g.) returns tailwind classes? 🤔

I think this is still a valid use case

Yes you're right and I would assume that some devs may have already configured Tailwind according to it and have their adaptive solutions - if anyone can post that'll be great. 😊

But as the warning mentions, these classes may not be in server files but possibly a shared JSON and/or the same classes are somewhere in the non-serverDir code as well - so server added classes aren't unique.

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