Use uno config in run-time.
<script lang='ts' setup>
console.log(__UNO__)
console.log(__UNO_CONFIG__)
console.log(__UNO_THEME__)
console.log(import.meta.env.__UNO__)
console.log(import.meta.env.__UNO_CONFIG__)
console.log(import.meta.env.__UNO_THEME__)
const presets = __UNO_CONFIG__.presets?.map((p: any) => p.name)
const transformers = import.meta.env.__UNO_CONFIG__.transformers?.map((t: any) => t.name)
</script>
pnpm add unplugin-unocss-config
Vite
// vite.config.ts
import UnoCSSConfig from 'unplugin-unocss-config/vite'
export default defineConfig({
plugins: [
UnoCSSConfig(),
],
})
// vite-env.d.ts
/// <reference types="unplugin-unocss-config/client" />
Example: playground/
Nuxt
// nuxt.config.js
export default {
buildModules: [
['unplugin-unocss-config/nuxt', { /* options */ }],
],
}
This module works for both Nuxt 2 and Nuxt Vite
MIT License © 2023-PRESENT Chris