-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
57 lines (53 loc) · 1.3 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
import react from '@vitejs/plugin-react'
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
const chrome = defineConfig({
build: {
lib: {
entry: resolve(import.meta.dirname, 'src/chrome/index.ts'),
name: 'cwskk',
fileName: 'background',
formats: ['es'],
},
outDir: 'dist/chrome',
},
})
const preview = defineConfig({
build: {
copyPublicDir: false,
outDir: 'dist/preview',
},
plugins: [react()],
})
// export default defineConfig({
// build: {
// rollupOptions: {
// input: {
// chrome: resolve('./src/chrome/index.ts'),
// preview: resolve('./src/preview/index.html'),
// },
// output: {
// entryFileNames: (chunkInfo) => {
// console.log(chunkInfo)
// return `entry/[name].js`
// },
// assetFileNames: (chunkInfo) => {
// console.log(chunkInfo)
// return `assets/[name].[ext]`
// },
// chunkFileNames: (chunkInfo) => {
// console.log(chunkInfo)
// return `chunks/[name].js`
// },
// },
// },
// },
// })
const target = process.env.TARGET
export default target === 'chrome'
? chrome
: target === 'preview'
? preview
: () => {
throw new Error('TARGET is not defined')
}