-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.ts
65 lines (64 loc) · 1.52 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
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import dts from 'vite-plugin-dts';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// command: 'vite build'. 'producton' is the default mode. Will build the lib.
if (mode === 'production') {
return {
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'vue-exit-intent',
fileName: (format) => `index.${format}.js`
},
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue'
}
}
},
minify: false
},
plugins: [
vue(),
dts({
insertTypesEntry: true,
rollupTypes: true,
tsconfigPath: './tsconfig.lib.json',
exclude: ['src/utils', 'src/tests']
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
};
} else if (mode === 'spa') {
// command: 'vite build --mode spa'. Will build our spa.
return {
build: {
outDir: 'dist-spa'
},
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
};
}
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
};
});