discuss
discuss copied to clipboard
We need something that generates thousand of classes without lagging in dev mode
I created custom plugin, it creates 2000 classes for pixel from 1px to 2000px, in production purge css removes unnecessary classes. I know that i can add dimensions in spacing, height, width in tailwind config js, but i wanna have plugin that generates classes. If i start dev mode console starts lagging so much. How to solve this problem?
That's an interesting idea for rapid prototyping. You can modify your build settings so that purgecss isn't run in a development environment. This generally speeds things up, anyway.
It can be done with postcss by checking NODE_ENV before adding purgecss to plugins, as per the documentation (where the example enables it only during production) https://tailwindcss.com/docs/controlling-file-size#setting-up-purgecss
const ENABLE_PURGECSS = process.env.NODE_ENV !== "development";
plugins: [
tailwindcss("./tailwind.config.js"),
ENABLE_PURGECSS && purgecss({ ... }),
// eg; autoprefixer should go here if you're using it
]
That's an interesting idea for rapid prototyping. You can modify your build settings so that purgecss isn't run in a development environment. This generally speeds things up, anyway.
It can be done with postcss by checking
NODE_ENVbefore adding purgecss to plugins, as per the documentation (where the example enables it only during production) https://tailwindcss.com/docs/controlling-file-size#setting-up-purgecssconst ENABLE_PURGECSS = process.env.NODE_ENV !== "development"; plugins: [ tailwindcss("./tailwind.config.js"), ENABLE_PURGECSS && purgecss({ ... }), // eg; autoprefixer should go here if you're using it ]
thanks, but purgecss is already disabled, still have lags
You're making your computer do a lot of work so it's going to be slower than the default build no matter what. But your CSS should only be recompiling if you change your Tailwind config or your CSS file, so it shouldn't be a big deal in practice unless you are actually changing that stuff a lot.
Can you share your project so we can see how it's all set up in case there are some easy wins possible?