@@ -2,16 +2,20 @@ import { dirname, join } from 'pathe'
22import { useNuxt , addTemplate , addTypeTemplate } from '@nuxt/kit'
33import type { ResolvedNuxtTemplate } from 'nuxt/schema'
44import type { ExposeConfig } from './types'
5- import { twCtx } from './context'
5+ import { twCtx } from './internal-context/ context'
66
77const NON_ALPHANUMERIC_RE = / ^ [ 0 - 9 a - z ] + $ / i
88const isJSObject = ( value : any ) => typeof value === 'object' && ! Array . isArray ( value )
99
1010export const createExposeTemplates = ( config : ExposeConfig , nuxt = useNuxt ( ) ) => {
1111 const templates : ResolvedNuxtTemplate < any > [ ] = [ ]
12- const getTWConfig = ( objPath : string [ ] = [ ] ) => objPath . reduce ( ( prev , curr ) => prev ?. [ curr ] , twCtx . tryUse ( ) as any )
1312
14- const populateMap = ( obj : any , path : string [ ] = [ ] , level = 1 ) => {
13+ const getTWConfig = (
14+ objPath : string [ ] = [ ] ,
15+ twConfig = twCtx . use ( ) . config ,
16+ ) => objPath . reduce ( ( prev , curr ) => prev ?. [ curr ] , twConfig as Record < string , any > )
17+
18+ const populateMap = ( obj : any = twCtx . use ( ) . config , path : string [ ] = [ ] , level = 1 ) => {
1519 Object . entries ( obj ) . forEach ( ( [ key , value = { } as any ] ) => {
1620 const subpathComponents = path . concat ( key )
1721 const subpath = subpathComponents . join ( '/' )
@@ -63,7 +67,7 @@ export const createExposeTemplates = (config: ExposeConfig, nuxt = useNuxt()) =>
6367 } )
6468 }
6569
66- populateMap ( twCtx . tryUse ( ) )
70+ populateMap ( )
6771
6872 const entryTemplate = addTemplate ( {
6973 filename : 'tailwind.config/index.mjs' ,
0 commit comments