-
Notifications
You must be signed in to change notification settings - Fork 15
/
vite.config.mjs
76 lines (74 loc) · 2.06 KB
/
vite.config.mjs
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
72
73
74
75
76
// @ts-check
/// <reference types="vitest">
import { readFile, writeFile } from 'node:fs/promises';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import yaml from '@rollup/plugin-yaml';
import emoji from './tasks/emoji.mjs';
import prerender from './tasks/prerender.mjs';
const inputPkg = new URL('./package.json', import.meta.url);
const outputPkg = new URL('./npm/package.json', import.meta.url);
export default defineConfig({
clearScreen: false,
legacy: {
// For the prerender plugin
proxySsrExternalModules: true,
},
resolve: {
alias: {
'@mui/base': '@mui/base/modern',
'@mui/icons-material': '@mui/icons-material/esm',
'@mui/material': '@mui/material/modern',
'@mui/styled-engine': '@mui/styled-engine/modern',
'@mui/system': '@mui/system/modern',
'@mui/utils': '@mui/utils/modern',
},
},
build: {
outDir: 'npm/public/',
assetsDir: 'static',
manifest: true,
},
server: {
port: 6041,
proxy: {
'/api/socket': {
target: 'http://127.0.0.1:6042',
ws: true,
},
'/api': {
target: 'http://127.0.0.1:6042',
},
},
watch: {
ignored: ['npm/**'],
},
},
plugins: [
react(),
yaml(),
prerender({ file: 'index.html', source: 'src/index.tsx' }),
prerender({ file: 'password-reset.html', source: 'src/password-reset/index.jsx' }),
prerender({ file: 'privacy.html', source: 'src/markdown.tsx', props: { path: 'static/privacy.md' } }),
emoji(),
{
name: 'u-wave-write-package-version',
apply: 'build',
async closeBundle() {
const { version } = JSON.parse(await readFile(inputPkg, 'utf8'));
const pkg = JSON.parse(await readFile(outputPkg, 'utf8'));
pkg.version = version;
await writeFile(outputPkg, `${JSON.stringify(pkg, null, 2)}\n`);
},
},
],
test: {
include: ['**/__tests__/*.{js,jsx,ts,tsx}'],
globals: true,
coverage: {
exclude: ['npm/**'],
},
environment: 'jsdom',
setupFiles: './test/setup.mjs',
},
});