-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvite.config.ts
84 lines (77 loc) · 2.25 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
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
77
78
79
80
81
82
83
84
import { defineConfig } from 'vite';
import { join, resolve } from 'path';
import { updateManifestPlugin } from './lib/patchPackage';
import { base64Loader } from './lib/base64loader';
import type { BuildTarget } from './lib/types';
import ClosePlugin from './lib/closePlugin';
import react from '@vitejs/plugin-react';
import million from "million/compiler";
//import MillionLint from '@million/lint';
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { chrome } from './src/manifests/chrome';
import { brave } from './src/manifests/brave';
import { edge } from './src/manifests/edge';
import { firefox } from './src/manifests/firefox';
import { opera } from './src/manifests/opera';
import { safari } from './src/manifests/safari';
import { crx } from '@crxjs/vite-plugin';
const targets: BuildTarget[] = [
chrome, brave, edge, firefox, opera, safari
]
const mode = process.env.MODE || 'chrome';
export default defineConfig(({ command }) => ({
plugins: [
base64Loader,
react(),
svelte({
emitCss: false
}),
million.vite({ auto: true }),
//MillionLint.vite(), /* enable for testing and debugging performance */
crx({
manifest: targets.find(t => t.browser === mode.toLowerCase())?.manifest ?? chrome.manifest,
browser: mode.toLowerCase() === "firefox" ? "firefox" : "chrome"
}),
updateManifestPlugin(),
...(command === 'build' ? [ClosePlugin()] : [])
],
root: resolve(__dirname, './src'),
resolve: {
alias: {
'@': resolve(__dirname, './src')
},
},
server: {
port: 5173,
hmr: {
host: "localhost",
protocol: "ws",
port: 5173
}
},
css: {
preprocessorOptions: {
scss: {
api: 'modern'
}
}
},
optimizeDeps: {
include: ['@babel/runtime/helpers/extends', '@babel/runtime/helpers/interopRequireDefault'],
},
legacy: {
skipWebSocketTokenCheck: true,
},
build: {
outDir: resolve(__dirname, 'dist', mode),
emptyOutDir: false,
minify: false,
rollupOptions: {
input: {
settings: join(__dirname, 'src', 'interface', 'index.html'),
migration: join(__dirname, 'src', 'seqta', 'utils', 'migration', 'migrate.html'),
pageState: join(__dirname, 'src', 'pageState.js'),
}
}
}
}));