-
Notifications
You must be signed in to change notification settings - Fork 121
/
vite.config.ts
48 lines (47 loc) · 1.5 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
import react from '@vitejs/plugin-react'
import fs from 'fs'
import { defineConfig } from 'vite'
import checker from 'vite-plugin-checker'
import { createHtmlPlugin } from 'vite-plugin-html'
import { VitePWA } from 'vite-plugin-pwa'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'react-native': 'react-native-web',
},
},
build: {
outDir: 'build',
},
plugins: [
react(),
// Do not run vite-plugin-checker during tests, as it will clear the test output.
// The dev server is usually running anyway, and tsc is run in lint:tsc which is triggered prepush.
...[!process.env.VITEST && !process.env.PUPPETEER ? checker({ typescript: true }) : undefined],
VitePWA({
injectRegister: null,
strategies: 'injectManifest',
srcDir: 'src',
filename: 'service-worker.ts',
injectManifest: {
maximumFileSizeToCacheInBytes: 4 * 1024 * 1024, // Increase limit to 4 MiB
},
}),
// minify and add EJS capabilities to index.html
createHtmlPlugin({ minify: true }),
],
...(process.env.PUPPETEER
? {
// Serve the dev server over HTTPS in puppeteer tests to enable clipboard access
server: {
https: {
key: fs.readFileSync('./src/e2e/puppeteer/puppeteer-key.pem'),
cert: fs.readFileSync('./src/e2e/puppeteer/puppeteer.pem'),
},
// Disable HMR in puppeteer tests to not interrupt running tests
hmr: false,
},
}
: {}),
})