how to send css while sending component as json ? #8965
-
hi, i am serving dynamic/async components in vue 3, sending components via json like below in runtime , i already have a tailwind/postcss generated css file for application, but for my dynamic components as i send below, i want to send css/stylesheet along the json !
thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Tailwind isn't really equipped for incremental builds like this, but what I think is that you would have to run Tailwind every time you send through one of these JSON packets. Instead of using const postcss = require('postcss');
const tailwind = require('tailwindcss');
/**
* Generates Tailwind CSS from given class names.
*
* @param {string} classNames Space-separated list of strings.
* @return {LazyResult} The process result.
*/
module.exports = classNames => postcss([tailwind({ safelist: classNames.split(' ') })])
.process('@tailwind base; @tailwind components; @tailwind utilities'); (Not sure if this code would actually run, but something like this! Taken from PostCSS JS API documentation) You could also see if Tailwind has a JavaScript API and do something similar without the need for PostCSS as an intermediary. |
Beta Was this translation helpful? Give feedback.
Tailwind isn't really equipped for incremental builds like this, but what I think is that you would have to run Tailwind every time you send through one of these JSON packets. Instead of using
tailwind.config.js
, you could runpostcss
with the Tailwind plugin and pass the Tailwind config inline. This gives you the chance to send the classes directly: