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

vite:css require is not defined #66

Open
MrVauxs opened this issue Dec 15, 2024 · 5 comments
Open

vite:css require is not defined #66

MrVauxs opened this issue Dec 15, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@MrVauxs
Copy link

MrVauxs commented Dec 15, 2024

Describe the bug
When attempting to use the plugin in Vite, vite errors during build from the plugin using the require() syntax.

Using commonjsOptions.transformMixedEsModules does not work, presumably since this is outside of Vite's jurisdiction.

To Reproduce
Code sandbox URL (any platform of your choice): TBD

Expected behaviour
The plugin to not block building.

Screenshots
Code_OTARe8mMq1

Desktop (please complete the following information):

  • OS: Windows
  • Version 3.7.10
  • Node v23.4.0
@MrVauxs MrVauxs added the bug Something isn't working label Dec 15, 2024
@MrVauxs
Copy link
Author

MrVauxs commented Dec 16, 2024

I am not sure if this is the correct way to go about this, but it removes the error while hopefully keeping the CJS compatibility.

const baseCssPath = typeof require !== 'undefined'
        ? require.resolve('tailwindcss/lib/css/preflight.css')
        : new URL('../../tailwindcss/lib/css/preflight.css', import.meta.url);

@Roman86
Copy link
Owner

Roman86 commented Dec 16, 2024

hi @MrVauxs ! Please see #63 , seems very similar to me. I have StackBlitz sandbox that works. Please provide yours if it doesn't help

@MrVauxs
Copy link
Author

MrVauxs commented Dec 18, 2024

By the looks of it, Stackblitz is hard-locked to Node v18 which is far behind current usage and you cannot update it.

Nonetheless, it seems that this issue may be related to tailwindlabs/tailwindcss#15374?

@Roman86
Copy link
Owner

Roman86 commented Dec 25, 2024

@MrVauxs great point, I guess you're right. Try updating to v3.4.17 as mentioned in that thread recently

@MrAlex94
Copy link

MrAlex94 commented Jan 9, 2025

FWIW, using this tailwind 4 + astro 5 example, this error shows up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants