-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathvite.config.mjs
62 lines (60 loc) · 1.82 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
import { readFile, writeFile } from 'node:fs/promises';
import { defineConfig, splitVendorChunkPlugin } from 'vite';
import react from '@vitejs/plugin-react';
import yaml from '@rollup/plugin-yaml';
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,
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,
// This will be filled in by the `prerender` plugin.
input: {},
},
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: [
splitVendorChunkPlugin(),
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.jsx', props: { path: 'static/privacy.md' } }),
{
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`);
},
},
],
});