From b672488b1164cc7f7b8971885c8c1ba30aee13f0 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Wed, 18 Jan 2023 03:12:48 -0500 Subject: [PATCH] [O] Optimize vite config --- vite.config.ts | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index e757589..80b59fa 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,28 +1,8 @@ -import path from "path"; - import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; +import path from "path"; -import tsconfig from "./tsconfig.json"; - -const tsconfigPathAliases = Object.fromEntries( - Object.entries(tsconfig.compilerOptions.paths).map(([key, values]) => { - let value = values[0]; - if (key.endsWith("/*")) { - key = key.slice(0, -2); - value = value.slice(0, -2); - } - - const nodeModulesPrefix = "node_modules/"; - if (value.startsWith(nodeModulesPrefix)) { - value = value.replace(nodeModulesPrefix, ""); - } else { - value = path.join(__dirname, value); - } - - return [key, value]; - }) -); +const src = path.resolve(__dirname, 'src') export default defineConfig({ plugins: [ @@ -30,7 +10,9 @@ export default defineConfig({ ], resolve: { alias: { - ...tsconfigPathAliases, + '@': src, + + // Runtime compilation vue: "vue/dist/vue.esm-bundler.js" }, dedupe: ['vue'],