Skip to content

Commit

Permalink
fix(nuxt): do not inject uno.css on dist-chunk mode (#2873)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Jul 16, 2023
1 parent 1afc2b6 commit 1e8fd12
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/nuxt/src/index.ts
Expand Up @@ -2,6 +2,7 @@ import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { addComponentsDir, addPluginTemplate, defineNuxtModule, extendWebpackConfig, isNuxt2, isNuxt3 } from '@nuxt/kit'
import WebpackPlugin from '@unocss/webpack'
import type { VitePluginConfig } from '@unocss/vite'
import VitePlugin from '@unocss/vite'
import type { NuxtPlugin } from '@nuxt/schema'
import { loadConfig } from '@unocss/config'
Expand Down Expand Up @@ -35,12 +36,15 @@ export default defineNuxtModule<UnocssNuxtOptions>({
// preset shortcuts
resolveOptions(options)

options.mode ??= 'global'
const InjectModes: VitePluginConfig['mode'][] = ['global', 'dist-chunk']

if (options.autoImport) {
addPluginTemplate({
filename: 'unocss.mjs',
getContents: () => {
const lines = [
'import \'uno.css\'',
InjectModes.includes(options.mode) ? 'import \'uno.css\'' : '',
isNuxt2()
? 'export default () => {}'
: 'import { defineNuxtPlugin } from \'#imports\'; export default defineNuxtPlugin(() => {})',
Expand Down

0 comments on commit 1e8fd12

Please sign in to comment.