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

Using the CLI, generating custom classnames creates a tailwindcss-classnames.ts file that is over 100MB #282

Closed
1 of 2 tasks
Dandandans opened this issue Oct 5, 2021 · 3 comments · Fixed by #281
Closed
1 of 2 tasks
Labels
bug Something isn't working

Comments

@Dandandans
Copy link

Dandandans commented Oct 5, 2021

Environment:

  • TailwindCSS version: 2.2.16
  • tailwindcss-classnames version: 2.2.3
  • Node.js version: 14.15.5

Current Behavior

After migrating Tailwind to JIT mode, using the CLI to generate custom classnames ouputs a tailwindcss-classnames.ts file that is over 112 MB. The previous size is 858 KB.

Expected Behavior

Generate a reasonably sized classnames file.

How to Reproduce

Run tailwindcss-classnames -i tailwind.config.js -x custom-tailwind-classes.ts -o tailwindcss-classnames.ts to generate classnames.

Possible solutions (Optional)

Additional Questions

  • I've searched the issues list and this is not a duplicate
  • I'm willing to fix this error
@Dandandans Dandandans added the bug Something isn't working label Oct 5, 2021
@muhammadsammy
Copy link
Owner

muhammadsammy commented Oct 6, 2021

This is because JIT engine produces a lot of additional classnames.

A workaround is to ignore the generated file by git and generate it locally and/or on CI e.g. if you have a "start" npm script that builds and starts the app, you would add a prestart script: "prestart": "tailwindcss-classnames -i tailwind.config.js -x custom-tailwind-classes.ts -o tailwindcss-classnames.ts" and the file will be generated every time you start the app.

I will also try to add minification feature to the CLI to reduce the size of generated file as possible

@chensusays
Copy link

I'm also seeing this issue due to JIT mode being enabled but adding the prestart script did not make difference for me. I'm turning JIT mode off for now but looks like Tailwind v3 will have JIT mode enabled as default.

@muhammadsammy
Copy link
Owner

Making the file ignored by Git and generating it automatically by prestart does not actually solve the whole problem, but it solves version control problem with large files.

Also as @Dandandans suggested, File size can be reduced with this alternative approach

@muhammadsammy muhammadsammy linked a pull request Oct 23, 2021 that will close this issue
8 tasks
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

Successfully merging a pull request may close this issue.

3 participants