-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Relative imports from tailwind.config.js result into errors with CLI #120
Comments
Read the code now at
The eval trick seems to be quite fragile, relying on certain format ( If textual representation is relied on, a proper e.g. esprima parser should be used. |
Thanks for reporting and the suggestions!
Totally agree. Using node's vm module seems like a great option that may prevent other potential issues with using eval too. A workaround that might work is to publish the tokens to npm or to add its contents directly to the tailwindconfig file by a script, but this would not be an acceptable solution. |
I'd suggest looking how tailwind cli itself handles imports like these before reinventing the wheel. Btw why don't you use |
I'm not sure if I understand this correctly, could you please elaborate more? |
I think it's quite useful for CLI user to have reasonable defaults — assuming most of us use default convention based configurations. |
It's set as the default for the prompt only. Maybe instead of falling back to the prompt if it's not supplied, CLI should prompt only if the |
Fixes #120 This is a workaround for errors from relative imports inside the config by using the `__dirname` global in imports
I managed to make a workaround by setting the This was released in |
|
You should pass the However, I noticed that running with npx does not work anymore, but the CLI works if "scripts": {
"generate-css-types": "tailwindcss-classnames -i path/to/tailwind.config.js"
} |
Still the same result when executing via
|
Thanks for trying! |
Ah yep that appears to be mine: config part referencing |
It should be fixed now by 0e401e3. Please update to the latest version (2.0.7) |
It works, thanks! |
Thank you for checking! |
We have design tokens specified in a separate
tokens.json
(located in the same directory relative to tailwind.config.js) file, which is populated automatically from Figma designs. This data is imported in ourtailwind.config.js
:When running
tailwindcss-classnames
command, this error happens:I replaced the node require import with direct file reading:
but it doesn't help, this error is thrown instead:
Looks like all relative imports or file reads from tailwind.config.js are going to break, since the
GeneratedFileWriter
resolves file paths relative to its own path (node_modules/tailwindcss-classnames/lib/cli/core) for generation purposes.The text was updated successfully, but these errors were encountered: