-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathvite.config.ts
71 lines (68 loc) · 1.87 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
/// <reference types="vitest" />
import { createRequire } from 'node:module';
import * as path from 'node:path';
import react from '@vitejs/plugin-react-swc';
import { defineConfig, loadEnv } from 'vite';
import checker from 'vite-plugin-checker';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import viteTsconfigPaths from 'vite-tsconfig-paths';
const require = createRequire(import.meta.url);
const ngeBase = path.dirname(
require.resolve('@osrd-project/netzgrafik-frontend/dist/netzgrafik-frontend/index.html')
);
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
return {
plugins: [
react(),
viteTsconfigPaths(),
checker({
typescript: {
buildMode: true,
},
eslint: {
lintCommand: 'eslint --cache --ext .ts,.tsx,.js,.jsx src --max-warnings 0',
},
overlay: env.OSRD_VITE_OVERLAY !== 'false' && {
initialIsOpen: env.OSRD_VITE_OVERLAY_OPEN_BY_DEFAULT === 'true',
},
}),
viteStaticCopy({
targets: [
{
src: [
path.join(ngeBase, 'node_modules_angular_common_locales_*_mjs.js'),
path.join(ngeBase, 'src_assets_i18n_*_json.js'),
],
dest: 'netzgrafik-frontend/',
},
],
}),
],
build: {
outDir: 'build',
sourcemap: true,
},
css: {
preprocessorOptions: {
scss: {
api: 'modern',
},
},
},
server: {
open: false,
port: +env.OSRD_VITE_PORT || 3000,
},
test: {
globalSetup: './vitest.global-setup.ts',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
environment: 'happy-dom',
coverage: {
all: true,
reportsDirectory: './tests/unit/coverage',
},
},
};
});