-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
52 lines (49 loc) · 1.33 KB
/
vite.config.ts
File metadata and controls
52 lines (49 loc) · 1.33 KB
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
import react from '@vitejs/plugin-react';
import { readFileSync } from 'fs';
import path from 'path';
import { defineConfig, Plugin } from 'vite';
import { buildCSP } from './src/main/shared/config/App.config';
const { version } = JSON.parse(readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8'));
function cspPlugin(): Plugin {
return {
name: 'inject-csp',
transformIndexHtml(html) {
return html.replace(
'<!--CSP-->',
`<meta http-equiv="Content-Security-Policy" content="${buildCSP()}" />`
);
},
};
}
export default defineConfig({
plugins: [react(), cspPlugin()],
base: './',
root: 'src/renderer',
define: { __APP_VERSION__: JSON.stringify(version) },
build: {
outDir: '../../dist/renderer',
emptyOutDir: true,
minify: 'terser',
terserOptions: {
compress: { drop_console: true },
format: { comments: false },
},
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes('node_modules/react') || id.includes('node_modules/react-dom')) {
return 'react-vendor';
}
},
},
},
reportCompressedSize: true,
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src/renderer'),
'@shared': path.resolve(__dirname, 'src/main/shared'),
},
},
server: { port: 5173 },
});