Skip to content

Posts tagged tailwindcss

Posts under this tag. Back to all posts when you want the full stream.

@latest_post

Import tailwind.config.cjs in Vite

Let's say you have a brand new Vue 3 + Vite project. You add Tailwind CSS to it and now you want to reference the config values inside a component.

Our goal will be to console.log(twConfig) to be able to browse the values in the console.

Easy enough, there seems to be some documentation for that right there in the official docs: Tailwind CSS - Referencing in JavaScript 

There is a problem though. Let's follow the instructions, add this to your src/App.vue file:

src/App.vue
import resolveConfig from 'tailwindcss/resolveConfig'
import tailwindConfig from '../tailwind.config.cjs'
const twConfig = resolveConfig(tailwindConfig)
console.log('twConfig', twConfig)