forked from Asvarox/allkaraoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
51 lines (45 loc) · 1.32 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 basicSsl from '@vitejs/plugin-basic-ssl';
import react from '@vitejs/plugin-react';
import analyze from 'rollup-plugin-visualizer';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
const fs = require('node:fs');
const certPath = './config/crt/server.pem';
const keyPath = './config/crt/server.key';
const customCert = fs.existsSync(certPath);
if (!customCert) {
console.log('No custom cert found, Service Worker might not work. Check README.md how to fix it');
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react({
babel: {
plugins: ['@emotion'],
},
}),
tsconfigPaths(),
analyze(),
!customCert && basicSsl(),
],
base: '/',
build: {
outDir: 'build',
},
server: {
port: 3000,
open: 'https://localhost:3000',
https: {
// Generated via https://letsencrypt.org/docs/certificates-for-localhost/#making-and-trusting-your-own-certificates
key: fs.readFileSync(customCert ? keyPath : './config/crt/dummy.key'),
cert: fs.readFileSync(customCert ? certPath : './config/crt/dummy.pem'),
},
},
test: {
include: ['**/*.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
globals: true,
environment: 'happy-dom',
setupFiles: 'src/setupTests.ts',
},
});