-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
51 lines (47 loc) · 1.55 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
/// <reference types="vitest" />
import { vitePlugin as remix } from '@remix-run/dev';
import { createRoutesFromFolders } from '@remix-run/v1-route-convention';
import react from '@vitejs/plugin-react';
import { remixRoutes } from 'remix-routes/vite';
import { defineConfig } from 'vite';
import { compression } from 'vite-plugin-compression2';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
const isTest = (mode: string): boolean => mode === 'test';
const isProd = (mode: string): boolean => mode === 'production';
const config = defineConfig(({ mode }) => ({
envPrefix: 'PUBLIC_',
plugins: [
tsconfigPaths(),
svgr({
include: '**/*.svg',
svgrOptions: {
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'],
},
}),
// remix v2 doesn't disable hmr in test mode, so we simply replace it with react plugin
isTest(mode)
? react()
: remix({
routes: r =>
createRoutesFromFolders(r, {
ignoredFilePatterns: ['**/_model/**.ts', '**/*.test.ts'],
}),
}),
remixRoutes({ strict: true, outDir: './app/types' }),
isProd(mode) && compression({ algorithm: 'gzip', compressionOptions: { level: 9 } }),
isProd(mode) && compression({ algorithm: 'brotliCompress' }),
],
test: {
globals: true,
environment: 'jsdom',
setupFiles: './vitest.setup.ts',
clearMocks: true,
coverage: {
provider: 'v8',
reporter: ['json-summary', 'json'],
reportOnFailure: true,
},
},
}));
export default config;