-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.js
50 lines (46 loc) · 1.14 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
import path from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
// https://vitejs.dev/config/
export default ({ command, mode }) => {
const isProd = command === 'build';
const config = {
mode: isProd ? 'production' : '',
server: {
port: 8080,
},
};
if (!isProd || mode === 'demo') {
config.root = `${process.cwd()}/demo`;
config.build = {
outDir: `${process.cwd()}/dist`,
emptyOutDir: true,
};
config.plugins = [vue()];
}
if (mode === 'lib') {
config.build = {
outDir: 'lib',
rollupOptions: {
external: ['vue'],
output: {
exports: 'named',
globals: {
vue: 'Vue',
},
},
},
lib: {
entry: path.resolve(__dirname, 'src/progressbar.js'),
name: 'VueNextProgressbar',
formats: ['es', 'cjs', 'umd'],
fileName: (format) => {
const name = `vue-next-progressbar.${format}`;
const extension = format === 'es' ? 'mjs' : 'js';
return `${name}.${extension}`;
},
},
};
}
return defineConfig(config);
};