Skip to content

Generate a static copy of Tailwind's config at build time using Vite's virtual module feature with TypeScript types

Notifications You must be signed in to change notification settings

maurer2/tailwind-config-via-vite-virtual-module

Repository files navigation

Accessing a Tailwind config in TypeScript

This repository demonstrates how to generate a static copy of Tailwind's configuration at build time using Vite's virtual module feature with proper TypeScript types. It serves as an alternative to the babel-plugin-preval or using Tailwind's resolveConfig helper directly.

Originally discovered here: Making Your Tailwind Config Available to Your Entire Application with Vite

Tailwind 4

The resolveConfig helper has been removed. Configuration variables can now only be accessed at runtime via window.getComputedStyle(). Refer to the official migration guide for more details.

About

Generate a static copy of Tailwind's config at build time using Vite's virtual module feature with TypeScript types

Topics

Resources

Stars

Watchers

Forks