-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.js
116 lines (110 loc) · 2.99 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
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
116
import rollupPluginReplace from '@rollup/plugin-replace';
import vue from '@vitejs/plugin-vue';
import { classes } from '@warp-ds/css/component-classes/classes';
import { presetWarp } from '@warp-ds/uno';
import uno from 'unocss/vite';
import { defineConfig } from 'vite';
import VitEik from 'viteik';
import { MinifyWarpLib } from './.minifier-plugin.js';
export default defineConfig((env) => ({
plugins: [
vue(),
uno({
presets: [presetWarp({ skipResets: true })],
safelist: classes,
}),
rollupPluginReplace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true,
}),
env.mode !== 'lib' && VitEik(),
MinifyWarpLib(),
],
server: { host: '0.0.0.0', port: 3003 },
test: {
globals: true,
environment: 'happy-dom',
include: ['./test/**'],
exclude: ['**.json'],
setupFiles: ['./setup.js'],
coverage: {
cleanOnRerun: true,
reporter: ['text'],
exclude: [
'**.json',
'dev/**',
'storybook-static/**',
'.storybook/**',
'components/**/stories',
'.minifier-plugin.js',
'lingui.config.ts',
'components/**/locales',
],
},
},
...getBuildOpts(env),
}));
function getBuildOpts(env) {
if (env.mode === 'production') {
return defineConfig({
build: { target: 'esnext' },
});
}
if (env.mode === 'lib') {
return defineConfig({
build: {
lib: {
entry: {
tabs: 'components/tabs/index.js',
switch: 'components/switch/index.js',
steps: 'components/steps/index.js',
slider: 'components/slider/index.js',
pill: 'components/pill/index.js',
modal: 'components/modal/index.js',
generic: 'components/generic/index.js',
forms: 'components/forms/index.js',
expandable: 'components/expandable/index.js',
card: 'components/card/index.js',
'button-group': 'components/button-group/index.js',
button: 'components/button/index.js',
breadcrumbs: 'components/breadcrumbs/index.js',
box: 'components/box/index.js',
badge: 'components/badge/index.js',
attention: 'components/attention/index.js',
alert: 'components/alert/index.js',
'warp-vue': './index.js',
},
formats: ['es'],
},
rollupOptions: {
external: ['vue'],
output: {
format: 'es',
dir: 'dist/',
entryFileNames: '[name].js',
assetFileNames: 'assets/[name].[ext]',
chunkFileNames: '[name].js',
},
},
},
});
}
if (env.mode === 'eik') {
return defineConfig({
build: {
emptyOutDir: false,
...getLibOpts('warp-vue.eik'),
},
});
}
}
function getLibOpts(fileName) {
return {
sourcemap: true,
lib: {
formats: ['es'],
entry: './index.js',
fileName,
},
};
}