mirror of
https://github.com/vitejs/vite.git
synced 2024-11-22 07:09:05 +00:00
24 lines
528 B
TypeScript
24 lines
528 B
TypeScript
import { defineConfig } from 'vite'
|
|
import type { Plugin } from 'vite'
|
|
|
|
export default defineConfig({
|
|
plugins: [slowModulePlugin()],
|
|
})
|
|
|
|
function slowModulePlugin(): Plugin {
|
|
return {
|
|
name: 'slow-module',
|
|
resolveId(id) {
|
|
if (id === 'virtual:slow-module') {
|
|
return '\0virtual:slow-module'
|
|
}
|
|
},
|
|
async load(id) {
|
|
if (id === '\0virtual:slow-module') {
|
|
await new Promise((resolve) => setTimeout(resolve, 500))
|
|
return `export const msg = '[success]'`
|
|
}
|
|
},
|
|
}
|
|
}
|