[O] Optimize vite config
This commit is contained in:
+5
-23
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user