-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
74 lines (73 loc) · 2.05 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
66
67
68
69
70
71
72
73
74
/// <reference types="vitest" />
import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import path from "path";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
VueI18nPlugin({
include: [path.resolve(__dirname, './frontend/locales/**')],
}),
],
mode: 'production',
define: {
'process.env.NODE_ENV': process.env.NODE_ENV === 'test' ? '"test"' : '"production"',
},
build: {
emptyOutDir: false,
lib: {
// what to build
name: 'OsisDocument',
// This is to have multiple UMD builds, until something like https://github.com/vitejs/vite/pull/10609
entry: process.env.VITE_BUILD_EDITOR ? 'frontend/editor.ts' : 'frontend/main.ts',
formats: ['umd'],
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled into library
external: ['vue', 'vue-i18n', '@vue/runtime-dom'],
output: {
// Provide global variables to use in the UMD build for externalized deps
globals: {
vue: 'Vue',
'vue-i18n': 'VueI18n',
'@vue/runtime-dom': 'Vue',
},
entryFileNames: (chunkInfo) => {
if (chunkInfo.name === 'editor') {
return 'osis-document-editor.umd.min.js';
}
return "osis-document.umd.min.js";
},
assetFileNames: () => {
if (process.env.VITE_BUILD_EDITOR) {
return 'osis-document-editor.[ext]';
}
return "osis-document.[ext]";
},
},
},
},
test: {
environment: 'jsdom',
setupFiles: ['frontend/test.setup.ts'],
minThreads:0,
maxThreads:1,
coverage: {
provider: 'istanbul',
all: true,
enabled: true,
perFile: true,
branches: 100,
statements: 100,
include: ['frontend'],
exclude: [
"frontend/locales/",
"frontend/node_modules/",
"frontend/.storybook",
"frontend/**/*.stories.{ts,js}",
],
},
},
});