[O] Optimize vite config

This commit is contained in:
Azalea Gui
2023-01-18 03:12:48 -05:00
parent 4b478ec8bb
commit b672488b11
+5 -23
View File
@@ -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'],