Skip to content

Commit 255361d

Browse files
committed
fix(sources)!: provide sources as object
1 parent 7214685 commit 255361d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/import-css.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ const getDefaults = (nuxtConfig: NuxtConfig & { srcDir: string }) => [
1212
].map(defaultPath => join(nuxtConfig.srcDir, nuxtConfig.dir?.assets || 'assets', defaultPath))
1313

1414
export default async function importCSS(nuxt = useNuxt()) {
15-
const sources = nuxt.options._layers.map(layer => JSON.stringify(layer.config.srcDir || layer.cwd))
15+
const sources = nuxt.options._layers.map(layer => ({ type: 'path', source: layer.config.srcDir || layer.cwd }))
1616

1717
// Add variables from Nuxt config that need parsing
1818
const sourceConfigs = [
1919
nuxt.options.app?.head?.htmlAttrs?.class,
2020
nuxt.options.app?.head?.bodyAttrs?.class,
2121
]
2222
sourceConfigs.forEach((value) => {
23-
if (value) sources.push(`inline(${JSON.stringify(value)})`)
23+
if (value && typeof value === 'string') sources.push({ type: 'inline', source: value })
2424
})
2525

2626
await nuxt.callHook('tailwindcss:sources:extend', sources)
2727

2828
const sourcesTemplate = addTemplate({
2929
filename: 'tailwindcss/sources.css',
30-
getContents: () => sources.map(source => `@source ${source};`).join('\n'),
30+
getContents: () => sources.map(s => `@source ${s.type === 'path' ? JSON.stringify(s.source) : `${s.type}(${s.source})`};`).join('\n'),
3131
write: true,
3232
})
3333

src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface ModuleHooks {
3636
/**
3737
* Allows extending sources for Tailwind CSS.
3838
*/
39-
'tailwindcss:sources:extend': (sources: string[]) => void
39+
'tailwindcss:sources:extend': (sources: Array<{ type: string, source: string }>) => void
4040
}
4141

4242
declare module '@nuxt/schema' {

0 commit comments

Comments
 (0)