diff --git a/package.json b/package.json index 39b6fdf..83a7685 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "typescript": "^4.6.4", "unocss": "^0.49.4", "unplugin-auto-import": "^0.13.0", - "unplugin-icons": "^0.15.2", "unplugin-vue-components": "^0.23.0", "vite": "^4.3.9", "vite-plugin-mock": "^3.0.0", diff --git a/scripts/vite/plugin.ts b/scripts/vite/plugin.ts index f4399ae..6c2cbf9 100644 --- a/scripts/vite/plugin.ts +++ b/scripts/vite/plugin.ts @@ -67,43 +67,25 @@ export default function plugin(): Plugin { configResolved(resolvedConfig) { config = resolvedConfig; - const defaultExt = config.mode === "development" ? "dev" : "prod"; - extension = config.env.VITE_EXTENTION || defaultExt; + extension = config.env.VITE_EXTENTION ?? config.isProduction ? "prod" : "dev"; }, - async transformIndexHtml(html) { + async transformIndexHtml() { const script = await getBuildInfo(); - const replacedHtml = html.replace(/__((\w|_|-)+)__/g, (match, p1) => { - return config.env[`VITE_${p1}`] || ""; - }); - return { - html: replacedHtml, - tags: [ - { - tag: "script", - injectTo: "body", - children: script, - }, - ], - }; - }, - - async resolveId(id, importer, options) { - if (!extension || !id.startsWith("/src")) { - return; - } - const resolution = await this.resolve(id, importer, { skipSelf: true, ...options }); - const targetPath = resolution?.id.replace(/\.([^.]*?)$/, `.${extension}.$1`); - if (targetPath && fs.existsSync(targetPath)) { - return targetPath; - } + return [ + { + tag: "script", + injectTo: "body", + children: script, + }, + ]; }, load(id) { if (!extension || !id.includes("src")) { return; } - if (id.includes("?")) { + if (id.includes("?vue")) { return; } const targetPath = id.replace(/\.([^.]*?)$/, `.${extension}.$1`); diff --git a/src/App.vue b/src/App.vue index ee22659..f6fb06d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@