forked from element-plus/element-plus
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathvite.config.ts
More file actions
115 lines (112 loc) · 3.68 KB
/
vite.config.ts
File metadata and controls
115 lines (112 loc) · 3.68 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { resolve } from 'path';
import { defineConfig, UserConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import dynamicImport from 'vite-plugin-dynamic-import';
import vueJsx from '@vitejs/plugin-vue-jsx';
import svgLoader from 'vite-svg-loader';
import { visualizer } from 'rollup-plugin-visualizer';
export default defineConfig(({ mode }) => {
const config: UserConfig = {
build: {
lib: {
name: 'crawlab-ui',
entry: resolve(__dirname, 'src/index.ts'),
fileName: 'crawlab-ui',
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: [
'vue',
'vue-router',
'vue-i18n',
'vuex',
'axios',
'element-plus',
'element-plus/es/locale/lang/en',
'element-plus/es/locale/lang/zh-cn',
'@element/icons',
'@fortawesome/fontawesome-svg-core',
'@fortawesome/free-brands-svg-icons',
'@fortawesome/free-regular-svg-icons',
'@fortawesome/free-solid-svg-icons',
'@fortawesome/vue-fontawesome',
'atom-material-icons',
'monaco-editor',
'chart.js',
'cron-parser',
'pinyin',
'humanize-duration',
'dayjs',
'cronstrue/i18n',
'javascript-time-ago',
'javascript-time-ago/locale/en',
'javascript-time-ago/locale/zh',
'clipboard',
],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
vue: 'Vue',
'vue-router': 'VueRouter',
'vue-i18n': 'VueI18n',
vuex: 'Vuex',
axios: 'axios',
'element-plus': 'ElementPlus',
'@element/icons-vue': 'ElementIconsVue',
'@fortawesome/fontawesome-svg-core': 'FontAwesomeSvgCore',
'@fortawesome/free-brands-svg-icons': 'FontAwesomeBrandsSvgIcons',
'@fortawesome/free-regular-svg-icons': 'FontAwesomeRegularSvgIcons',
'@fortawesome/free-solid-svg-icons': 'FontAwesomeSolidSvgIcons',
'@fortawesome/vue-fontawesome': 'FontAwesomeVue',
'atom-material-icons': 'AtomMaterialIcons',
'monaco-editor': 'monaco-editor',
'chart.js': 'ChartJS',
'cron-parser': 'cronParser',
pinyin: 'pinyin',
'humanize-duration': 'humanizeDuration',
dayjs: 'dayjs',
'cronstrue/i18n': 'cronstrueI18n',
'javascript-time-ago': 'javascriptTimeAgo',
'javascript-time-ago/locale/en': 'javascriptTimeAgoLocaleEn',
'javascript-time-ago/locale/zh': 'javascriptTimeAgoLocaleZh',
'element-plus/es/locale/lang/en': 'elementPlusLocaleEn',
'element-plus/es/locale/lang/zh-cn': 'elementPlusLocaleZh',
clipboard: 'ClipboardJS',
},
},
},
},
optimizeDeps: {
include: ['element-plus', 'monaco-editor'],
},
resolve: {
dedupe: ['vue', 'vue-router', 'vuex', 'axios', 'element-plus'],
alias: {
'@': resolve(__dirname, 'src'),
},
extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
plugins: [
vue(),
// @ts-ignore
dynamicImport(),
vueJsx(),
// @ts-ignore
svgLoader(),
],
server: {
cors: true,
},
};
if (mode === 'analyze') {
// @ts-ignore
config.plugins.push(visualizer({ open: true, gzipSize: true }));
} else if (mode === 'development') {
config.build.watch = {
include: ['src/**', 'public', 'index.html'],
};
}
return config;
});