-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
56 lines (52 loc) · 1.41 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
import { defineConfig, loadEnv } from 'vite';
import vuePlugin from '@vitejs/plugin-vue';
import path from 'path';
import eslintPlugin from 'vite-plugin-eslint';
import istanbulPlugin from 'vite-plugin-istanbul';
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
const isTest = process.env.NODE_ENV === 'test';
const testPlugins = isTest ? [
istanbulPlugin({
include: 'src/*',
exclude: ['node_modules', 'tests'],
cypress: true,
checkProd: false,
// forceBuildInstrument: true, // Should be `true` on "build:test" and `false` on "serve:test"
}),
] : [];
return defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'mirage-setup': isTest ? path.resolve(__dirname, './tests/mirage/index') : path.resolve(__dirname, './tests/mirage/stub'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
build: {
outDir: isTest ? 'dist-e2e' : 'dist',
target: 'esnext',
minify: false,
},
plugins: [
vuePlugin(),
eslintPlugin({
cache: false,
}),
...testPlugins,
],
server: {
watch: {
ignored: [
'coverage/**/*',
'dist/**/*',
'dist-e2e/**/*',
'.nyc_output/**/*',
],
},
},
optimizeDeps: {
exclude: ['coverage'],
},
});
};