mirror of
https://github.com/alex8088/electron-vite.git
synced 2026-11-02 14:51:51 +08:00
16 lines
391 B
TypeScript
16 lines
391 B
TypeScript
import type { Plugin } from 'vite'
|
|
|
|
export default function importMetaUrlPlugin(): Plugin {
|
|
return {
|
|
name: 'vite:import-meta-url',
|
|
apply: 'build',
|
|
enforce: 'pre',
|
|
resolveImportMeta(property, { format }): string | null {
|
|
if (property === 'url' && format === 'cjs') {
|
|
return `require("url").pathToFileURL(__filename).href`
|
|
}
|
|
return null
|
|
}
|
|
}
|
|
}
|