-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
45 lines (39 loc) · 1.09 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
import { defineConfig, type PluginOption } from 'vite'
import react from '@vitejs/plugin-react-swc'
import * as path from 'node:path'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)
const ROOT = path.dirname(__filename)
// https://vitejs.dev/config/
const CHROME_VERSION = 122
const cspMate = `<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">`
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const htmlPlugin: () => PluginOption = () => {
return {
name: 'html-transform',
apply: 'build',
transformIndexHtml(html: string) {
return html.replace(/<title>/, `${cspMate}\n\t\t<title>`)
},
}
}
export default defineConfig({
root: path.join(ROOT, 'src'),
base: './',
plugins: [react()],
resolve: {
alias: {
'@': path.join(ROOT, 'src'),
},
},
build: {
target: `chrome${CHROME_VERSION}`,
outDir: path.join(ROOT, 'dist/renderer'),
emptyOutDir: true,
rollupOptions: {
input: {
main: path.join(ROOT, 'src/index.html'),
},
},
},
})