[O] Optimize vite config
This commit is contained in:
+5
-23
@@ -1,28 +1,8 @@
|
|||||||
import path from "path";
|
|
||||||
|
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
import tsconfig from "./tsconfig.json";
|
const src = path.resolve(__dirname, 'src')
|
||||||
|
|
||||||
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];
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
@@ -30,7 +10,9 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
...tsconfigPathAliases,
|
'@': src,
|
||||||
|
|
||||||
|
// Runtime compilation
|
||||||
vue: "vue/dist/vue.esm-bundler.js"
|
vue: "vue/dist/vue.esm-bundler.js"
|
||||||
},
|
},
|
||||||
dedupe: ['vue'],
|
dedupe: ['vue'],
|
||||||
|
|||||||
Reference in New Issue
Block a user