Skip to content

Commit e6a9e5e

Browse files
committed
Update vite config and ts to alias @
1 parent 2074e42 commit e6a9e5e

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"emitDeclarationOnly": true,
88
"outDir": "dist",
99
"strict": true,
10-
"skipLibCheck": true
10+
"skipLibCheck": true,
11+
"paths": {
12+
"@/*": ["./src/*"]
13+
}
1114
},
1215
"exclude": ["node_modules", "dist"],
1316
"include": ["src/**/*"]

vite.config.js

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
import { defineConfig } from "vite";
22
import path from "path";
33
import { version } from "./package.json";
4+
import { fileURLToPath, URL } from "node:url";
45

5-
export default defineConfig({
6-
resolve: {
7-
alias: {
8-
'chartjs': 'chart.js',
9-
}
10-
},
11-
build: {
12-
minify: true,
13-
lib: {
14-
entry: path.resolve(__dirname, "src/main.js"),
15-
name: "MCT",
16-
fileName: () => `mct-${version}.js`,
17-
18-
formats: ['umd']
6+
export default defineConfig(({ command, mode }) => {
7+
const isBuild = command === 'build';
8+
return {
9+
resolve: {
10+
alias: {
11+
'chartjs': 'chart.js',
12+
'vue': 'vue/dist/vue.esm-bundler.js',
13+
"@": fileURLToPath(new URL("./src", import.meta.url)),
14+
}
1915
},
20-
rollupOptions: {
21-
output: {
22-
assetFileNames: `mct-${version}.[ext]`,
16+
build: {
17+
minify: true,
18+
lib: {
19+
entry: path.resolve(__dirname, "src/main.js"),
20+
name: "MCT",
21+
fileName: () => `mct-${version}.js`,
22+
23+
formats: ['umd']
24+
},
25+
rollupOptions: {
26+
output: {
27+
assetFileNames: `mct-${version}.[ext]`,
28+
},
2329
},
2430
},
25-
},
26-
define: {
27-
'process.env.NODE_ENV': '"production"',
28-
'__VUE_OPTIONS_API__': true,
29-
'__VUE_PROD_DEVTOOLS__': true,
30-
},
31+
define: {
32+
'process.env.NODE_ENV': isBuild ? '"production"' : '"development"',
33+
'__VUE_OPTIONS_API__': !isBuild,
34+
'__VUE_PROD_DEVTOOLS__': !isBuild,
35+
'__VUE_PROD_HYDRATION_MISMATCH_DETAILS__': !isBuild
36+
}
37+
}
3138
});

0 commit comments

Comments
 (0)