-
Notifications
You must be signed in to change notification settings - Fork 46
/
vite.config.ts
66 lines (63 loc) · 1.75 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { resolve } from "node:path";
import vue from "@vitejs/plugin-vue";
import svgLoader from "vite-svg-loader";
import terser from "@rollup/plugin-terser";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { defineConfig, type UserConfig } from "vite";
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
const lifecycle = process.env.npm_lifecycle_event;
function getConfigs(): UserConfig {
return lifecycle === "lib"
? {
publicDir: false,
build: {
lib: {
entry: resolve(__dirname, "packages/index.ts"),
name: "PureTable",
fileName: format => `index.${format}.js`
},
// https://rollupjs.org/guide/en/#big-list-of-options
rollupOptions: {
treeshake: true,
external: ["vue", "element-plus"],
output: {
globals: {
vue: "Vue",
"element-plus": "ElementPlus"
},
exports: "named"
},
plugins: [terser({ compress: { drop_console: true } })]
}
}
}
: ({
base: "/pure-admin-table/",
build: {
sourcemap: false,
chunkSizeWarningLimit: 4000
}
} as any);
}
// https://cn.vitejs.dev/guide/build.html#library-mode
export default defineConfig({
plugins: [
vue(),
vueJsx(),
svgLoader(),
VueI18nPlugin({
runtimeOnly: true,
compositionOnly: true,
include: [resolve(__dirname, "locales/**")]
})
],
// https://cn.vitejs.dev/guide/build.html#library-mode 环境变量
define: {
"process.env.NODE_ENV": '"production"',
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
},
server: {
host: "0.0.0.0"
},
...getConfigs()
});