diff --git a/docs/content/1.getting-started/2.options.md b/docs/content/1.getting-started/2.options.md index e2ef8d97..f57a1a47 100644 --- a/docs/content/1.getting-started/2.options.md +++ b/docs/content/1.getting-started/2.options.md @@ -33,6 +33,20 @@ export default { This file will be directly injected as a [global CSS](https://v3.nuxtjs.org/api/configuration/nuxt.config#css) for Nuxt. It supports `css`, `sass`, `postcss`, and more. +If you don't want to inject CSS file, you can set `cssPath` to `false`. + +```ts [nuxt.config] +export default { + tailwindcss: { + cssPath: false, + } +} +``` + +::alert{type="warning"} +When set to `false`, note that HMR for tailwindcss will be broken (hard refresh needed). +:: + ## `configPath` - Default: `'tailwind.config'` diff --git a/src/module.ts b/src/module.ts index 3f1b6913..a26b4fac 100644 --- a/src/module.ts +++ b/src/module.ts @@ -43,7 +43,7 @@ type Arrayable = T | T[] export interface ModuleOptions { configPath: Arrayable; - cssPath: string; + cssPath: string | false; config: Config; viewer: boolean; exposeConfig: boolean; @@ -170,7 +170,7 @@ export default defineNuxtModule({ * CSS file handling */ - const cssPath = await resolvePath(moduleOptions.cssPath, { extensions: ['.css', '.sass', '.scss', '.less', '.styl'] }) + const cssPath = typeof moduleOptions.cssPath === 'string' ? await resolvePath(moduleOptions.cssPath, { extensions: ['.css', '.sass', '.scss', '.less', '.styl'] }) : false // Include CSS file in project css let resolvedCss: string @@ -183,6 +183,9 @@ export default defineNuxtModule({ // @ts-ignore resolvedCss = createResolver(import.meta.url).resolve('runtime/tailwind.css') } + } else { + logger.info('No Tailwind CSS file found. Skipping...') + resolvedCss = createResolver(import.meta.url).resolve('runtime/empty.css') } nuxt.options.css = nuxt.options.css ?? [] const resolvedNuxtCss = await Promise.all(nuxt.options.css.map(p => resolvePath(p))) diff --git a/src/runtime/empty.css b/src/runtime/empty.css new file mode 100644 index 00000000..e69de29b