Skip to content

Commit b2191fa

Browse files
committed
fix: handle scan on vite
closes #65
1 parent 8f84cd1 commit b2191fa

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/index.ts

+29
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,34 @@ export default createUnplugin<Options | undefined, false>((rawOptions = {}) => {
5757

5858
return generateTransform(s, id)
5959
},
60+
61+
vite: {
62+
config(config, { command }) {
63+
if (command !== 'serve') return
64+
return {
65+
optimizeDeps: {
66+
esbuildOptions: {
67+
plugins: [
68+
{
69+
name: `${name}-optimize-deps`,
70+
setup(build) {
71+
build.onLoad({ filter: /\.vue($|\?)/ }, async (args) => {
72+
const resolvedName = await (
73+
options.resolveName || resolveName
74+
)(args.path)
75+
let js = `export const ${resolvedName} = {}`
76+
if (!options.removeDefault) {
77+
js += `\nexport default ${resolvedName}`
78+
}
79+
return { contents: js }
80+
})
81+
},
82+
},
83+
],
84+
},
85+
},
86+
}
87+
},
88+
},
6089
}
6190
})

0 commit comments

Comments
 (0)