Vite with Storybook 8 require is not defined
when importing cjs file
#28659
Unanswered
LordZardeck
asked this question in
Help
Replies: 1 comment
-
I am experiencing this too. Seemingly after upgrading Node. This smells like a configuration tweak however I'm not exactly sure what the pressure point is. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Currently I have a UI package in my monorepo that's using storybook. Vite is configured, and properly builds with 0 issues. However, when running storybook and opening a story that contains a component that imports a CJS file, i get the error:
require is not defined
. The reason I have to import a CJS file, is that the tailwind config needs to be in CJS format, but I want to import it to process it withtailwindcss/resolveConfig
to utlize some of the configuration values at runtime.Given that Vite can bundle everything correctly, I'm confused as to why this is an issue in storybook.
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions