You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like breaking down my config file into several files because they can get huge (especially with extended colors, grids, etc) and most keys don't require me to pass functions, so for the most part these files are serializable and hence I choose YAML as my preferred format to store these key value pairs for readability and the additional benefit to make pretty comments, like my screens.yaml shown below:
# ======================================## ░█▀▀░█▀▀░█▀▄░█▀▀░█▀▀░█▀█░█▀▀# ░▀▀█░█░░░█▀▄░█▀▀░█▀▀░█░█░▀▀█# ░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀░▀░▀▀▀## If you want to get finer control# over styling for various kinds of# screen sizes, you can extend your# configuration to use the following# keys. These devices overlap with# those available in Google Chrome# (default breakpoints) so you won't# have to think twice with these.## ======================================screens:
mobile:
max: 767pxmobile-sm:
max: 320pxmobile-md:
min: 321pxmax: 375pxmobile-lg:
min: 376pxmax: 425pxmobile-xl:
min: 426pxmax: 767pxtablet:
min: 768pxmax: 991pxtabloid:
max: 991pxdesktop:
min: 992pxdesktop-sm:
min: 992pxmax: 1024pxdesktop-md:
min: 1025pxmax: 1440pxdesktop-lg:
min: 1441pxmax: 1920pxdesktop-4k:
min: 1921pxmax: 2560pxdesktop-8k:
min: 2561px
But currently, if I wish to import YAML files, I'll have to create another JS file like so:
importfsfrom"node:fs"importyamlfrom"js-yaml"/* ====================================== ░█░█░█▀█░█▄█░█░░ ░░█░░█▀█░█░█░█░░ ░░▀░░▀░▀░▀░▀░▀▀▀ This file exports a simple function to load YAML files from their paths. Path must be relative to project root, and must not use local aliases. ======================================*/exportconstread=path=>{try{constfile=yaml.load(fs.readFileSync(`${path}`,"utf8"))constindentedJson=JSON.stringify(file,null,2)returnfile}catch(e){console.log(e)}}exportdefault{
read
}
And then import my screens.yaml file into my tailwind.config.js file like so:
But, I wish there was a YAML loader support already for tailwind config files. Or at least a way to plug it in if we wish to in our project because custom loaders make the DX better as they reduces that one custom YAML loader (in this case) from our projects.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I like breaking down my config file into several files because they can get huge (especially with extended colors, grids, etc) and most keys don't require me to pass functions, so for the most part these files are serializable and hence I choose YAML as my preferred format to store these key value pairs for readability and the additional benefit to make pretty comments, like my
screens.yaml
shown below:But currently, if I wish to import YAML files, I'll have to create another JS file like so:
And then import my
screens.yaml
file into mytailwind.config.js
file like so:But, I wish there was a YAML loader support already for tailwind config files. Or at least a way to plug it in if we wish to in our project because custom loaders make the DX better as they reduces that one custom YAML loader (in this case) from our projects.
Beta Was this translation helpful? Give feedback.
All reactions