Skip to content

Commit

Permalink
fix(vite): dedupe @iconify/vue by default
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Nov 10, 2024
1 parent fd46c6e commit 8b1d75c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,20 @@ export default defineNuxtModule<ModuleOptions>({
throw new TypeError('`customize` callback can\'t not be set in module options, use `app.config.ts` or component props instead.')
}

// Use `server` provider when SSR is disabled or generate mode
if (!options.provider) {
// Use `server` provider when SSR is disabled or generate mode
options.provider = (!nuxt.options.ssr || nuxt.options._generate)
? 'iconify'
: 'server'
}

// In some monorepo, `@iconify/vue` might be bundled twice which does not share the loaded data
nuxt.options.vite ||= {}
nuxt.options.vite.resolve ||= {}
nuxt.options.vite.resolve.dedupe ||= []
nuxt.options.vite.resolve.dedupe.push('@iconify/vue')

// Create context
const ctx = new NuxtIconModuleContext(nuxt, options)

addPlugin(
Expand Down Expand Up @@ -90,7 +97,6 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.options.appConfig.icon || {},
runtimeOptions,
)

// Define types for the app.config compatible with Nuxt Studio
nuxt.hook('schema:extend', (schemas) => {
schemas.push({
Expand Down

0 comments on commit 8b1d75c

Please sign in to comment.