-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
44 lines (42 loc) · 1.12 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
import { resolve } from 'path';
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import manifest from './vite/Manifest';
import properHtml from './vite/ProperHtml';
export default defineConfig(({ mode }) => {
return {
plugins: [
solidPlugin(),
properHtml([{ from: 'src/popup/index.html', to: 'popup.html' }]),
manifest(mode === 'firefox' ? 'v2' : undefined),
],
publicDir: 'public',
build: {
target: 'es6',
outDir: getBuildDir(mode),
sourcemap: mode === 'dev',
rollupOptions: {
input: {
popup: resolve('src/popup/index.html'),
content: resolve('src/content/content.ts'),
opinionator: resolve('src/webres/opinionator.ts'),
},
output: {
entryFileNames: '[name].js',
assetFileNames: `[name].[ext]`,
chunkFileNames: '[name].js',
},
},
},
};
});
function getBuildDir(mode: string): string {
switch (mode) {
case 'chrome':
return 'build-chrome';
case 'firefox':
return 'build-firefox';
default:
return 'build';
}
}