How could you generate multiple CSS files at once? #6612
-
I want to have multiple inputs/outputs for tailwind. Doing |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 10 replies
-
Looking at https://tailwindcss.com/docs/reusing-styles, I can see that this is a design choice to not do this. However, the recommended method is
What if I use vanilla JS? What if I don't want to use JS at all? |
Beta Was this translation helpful? Give feedback.
-
This all kind of depends what you are actually trying to even do here.
Regarding this question:
That's why we say template partial or JavaScript component. Template partials can be ERB templates in Rails, partials in Django, Blade files in Laravel, whatever. This doesn't really seem related to the original question of compiling multiple files though so I'm still unsure what you are actually trying to do. My best guess is you want to have a separate CSS file for each "component" in your site? If that's the case just make separate files, and import them all into one main CSS file, then process that with Tailwind. Same thing you would do with Sass or whatever. Personal advice though is that if you are planning to write a lot of custom CSS like this when using Tailwind, you probably just shouldn't use Tailwind. Tailwind is for styling things directly in your HTML with utility classes, if you aren't doing that you are just going to have a bad experience because that's what the framework is for. |
Beta Was this translation helpful? Give feedback.
-
Multiple compile comes useful for web-components. |
Beta Was this translation helpful? Give feedback.
-
i needed it for 2 different styles: i was initially gonna use i went with wrapping my css files within print.css@media print {
/* write styles for the print here */
} screen.css@media screen {
/* write styles for the web here */
} index.css@import 'tailwindcss/base';
/* use this to style the web */
@import './screen.css';
/* use this only for print */
@import './print.css';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities'; this way i only have to build one |
Beta Was this translation helpful? Give feedback.
-
Stumbled again: we have many components with corresponding css files under |
Beta Was this translation helpful? Give feedback.
-
If someone is interested in workaround, it would be that:
Every file runs tailwind command, so it takes a bit of time. |
Beta Was this translation helpful? Give feedback.
This all kind of depends what you are actually trying to even do here.
You want to compile multiple input files into multiple output files, all with their own
tailwind.config.js
configuration. In this case your best bet is to just run Tailwind multiple times with different arguments. You can use a package likenpm-run-all
orconcurrently
to bundle this all up into one script.You want to compile multiple input files into a single output file. What you probably want here is to actually just compile a single file, but use
postcss-import
to import all of your individual files into one file before processing it with Tailwind. Here's some documentation on that: https://tailwindcss.com/docs…