tailwind.config.js into your theme build, recommended Tailwind settings, and how to produce a small, production-ready CSS bundle.
Integrating tailwind.config.js
- Put the generated
tailwind.config.jsin the theme root (themes/<theme>/tailwind.config.js). - Create a small entry CSS file (e.g.,
src/input.css):
- Build using Tailwind CLI or via a bundler:
Recommended Tailwind config options
- Enable JIT / Just-In-Time mode (for latest Tailwind versions this is default).
- Set
contentpaths narrowly to your theme’ssrcandcomponentsdirectories to avoid bloated CSS. - Configure
safelistfor dynamic classes used by the template engine.
Purging & Size
- Use
contentpaths to ensure unused utilities are removed. - Avoid generating full Tailwind in each theme; instead, prefer a shared base and theme-specific extensions when possible.
Runtime token injection
- Build produces CSS and a small token stylesheet (CSS variables). At runtime inject the token stylesheet before the theme CSS to ensure CSS variables are available.
Example build script (package.json)
Testing
- Run a local static server to preview compiled HTML + CSS.
- Use
npx serve distorlive-serverto quickly inspect pages.