-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
vite.config.ts
69 lines (65 loc) · 1.67 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
/// <reference types="vitest" />
import eslintPlugin from '@nabla/vite-plugin-eslint';
import react from '@vitejs/plugin-react';
import type { UserConfigExport } from 'vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
process.env.BASE_PATH = '/';
const base: UserConfigExport = {
plugins: [
tsconfigPaths(),
react(),
...(mode === 'test' ? [] : [eslintPlugin()])
],
optimizeDeps: {
disabled: false
},
test: {
css: false,
include: ['./src/**/__tests__/*', './src/__tests__/**/*.spec.ts'],
globals: true,
clearMocks: true,
coverage: {
provider: 'istanbul',
enabled: true,
reporter: ['text', 'lcov'],
reportsDirectory: 'coverage'
},
environment: 'jsdom',
setupFiles: './src/setupTests.ts'
},
build: {
commonjsOptions: {
include: []
},
sourcemap: false,
minify: true,
emptyOutDir: true,
outDir: 'dist',
rollupOptions: {
treeshake: true,
output: {
chunkFileNames: 'bundle/[name].[hash].js',
// eslint-disable-next-line consistent-return
manualChunks: id => {
if (id.includes('node_modules')) {
return 'vendor';
}
}
}
}
}
};
// Github publish content based on the repo name.
// For vercel, we need to keep the base path as /.
if (mode !== 'vercel') {
process.env.BASE_PATH = '/drg-editor/';
return {
...base,
base: process.env.BASE_PATH
};
}
return base;
});