Skip to content

Commit aaed0ad

Browse files
committed
chore: fixed id error
1 parent 53173e4 commit aaed0ad

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/index.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
import { createUnplugin } from 'unplugin'
22
import chokidar from 'chokidar'
3-
import createDebugger from 'debug'
43
import type { ResolvedConfig, ViteDevServer } from 'vite'
54
import type { Options } from './types'
65
import { UNPLUGIN_NAME } from './core/constants'
76
import { generateComponentFromPath, generateImagePath, isImagePath, normalizeImagePath } from './core/loader'
87
import { Context } from './core/context'
98

10-
const debug = createDebugger(`${UNPLUGIN_NAME}:unplugin`)
11-
129
const unplugin = createUnplugin<Options>((options = {}) => {
1310
const ctx = new Context(options)
1411

1512
return {
1613
name: UNPLUGIN_NAME,
1714
enforce: 'pre',
15+
resolveId(id) {
16+
if (isImagePath(id))
17+
return generateImagePath(normalizeImagePath(id))
18+
return null
19+
},
1820
loadInclude(id) {
1921
return isImagePath(id)
2022
},
2123
load(id) {
2224
if (isImagePath(id)) {
23-
debug('load id =>', id)
24-
id = generateImagePath(normalizeImagePath(id))
25-
debug('resolved id =>', id)
2625
const config = ctx.options
27-
debug('load config =>', config)
2826
return generateComponentFromPath(id, config, ctx)
2927
}
3028
return null

0 commit comments

Comments
 (0)