-
Notifications
You must be signed in to change notification settings - Fork 235
/
Copy pathvite.config.js
62 lines (60 loc) · 1.34 KB
/
vite.config.js
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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import { createHtmlPlugin } from 'vite-plugin-html'
export default ({ mode }) => {
const DEV = mode === 'development'
const BUILD_EXAMPLE = mode === 'example'
let config = {
plugins: [
vue(),
createHtmlPlugin({
inject: {
data: {
DEV: DEV,
EXAMPLE: BUILD_EXAMPLE,
},
},
}),
],
resolve: {
extensions: ['.js', '.json', '.vue'],
},
}
if (DEV || BUILD_EXAMPLE) {
config.root = resolve(__dirname, 'examples/')
config.resolve.alias = {
'@': resolve(__dirname, './src'),
}
config.server = {
host: '0.0.0.0',
}
} else {
config.build = {
cssCodeSplit: true,
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue',
},
},
},
lib: {
entry: 'src/index.js',
name: 'VDistpicker',
formats: ['umd'],
fileName: () => 'v-distpicker.js',
},
}
}
if (BUILD_EXAMPLE) {
config.publicDir = 'static'
config.build = {
outDir: '../dist-examples',
emptyOutDir: true,
}
config.base = './'
}
return defineConfig(config)
}