Skip to content

Commit

Permalink
fix: dts generator can be done earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
Jevon617 committed Nov 27, 2024
1 parent 9c32d70 commit 9c0d313
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ export async function genCode(options: Options, spriteInfo: SvgSpriteInfo, isDev
const insertSvgCode = isDynamic ? genInsertSvgCode(sprite) : ''
const componentCode = await genComponentCode(options)

// only generate dts in serve
if (options?.dts && isDev)
genDts(symbolIds, options)

const hmrCode = `
if (import.meta.hot) {
import.meta.hot.on("${LOAD_EVENT}", ({ sprite }) => {
Expand Down
5 changes: 4 additions & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cors from 'cors'
import genEtag from 'etag'
import { createUnplugin } from 'unplugin'
import type { Options, SvgSpriteInfo } from '../types'
import { genCode } from './generator'
import { genCode, genDts } from './generator'
import { MODULE_NAME, PLUGIN_NAME } from './constants'
import { resolveOptions } from './utils'
import createSvgSprite from './sprite'
Expand All @@ -21,6 +21,9 @@ const unplugin = createUnplugin<Options>(options => ({
options = resolveOptions(options)
spriteInfo = await createSvgSprite(options, isBuild)
isDynamicStrategy = options.domInsertionStrategy === 'dynamic'
// only generate dts in serve
if (options?.dts && !isBuild)
genDts(spriteInfo.symbolIds, options)
},
resolveId(id: string) {
if (id === MODULE_NAME)
Expand Down

0 comments on commit 9c0d313

Please sign in to comment.