-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
39 lines (37 loc) · 1.35 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import copy from 'rollup-plugin-copy'
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
root: 'src/',
plugins: [react(),
copy({
targets: [
{ src: 'manifest.json', dest: 'dist' }, // 复制 manifest.json 到 dist 目录
{ src: "src/icons/**", dest: 'dist/icons' } // 复制 src/icons/** 到 dist/icons 目录
]
})
],
build: {
outDir: path.resolve(__dirname, 'dist'),
rollupOptions: {
input: {
popup: path.resolve(__dirname, 'src/popup/index.html'),
contentPage: path.resolve(__dirname, 'src/contentPage/index.html'),
content: path.resolve(__dirname, 'src/content/content.ts'),
background: path.resolve(__dirname, 'src/background/service-worker.ts'),
},
output: {
assetFileNames: 'assets/[name]-[hash].[ext]', // 静态资源
chunkFileNames: 'js/[name]-[hash].js', // 代码分割中产生的 chunk
entryFileNames: (chunkInfo) => { // 入口文件
const baseName = path.basename(chunkInfo.facadeModuleId!, path.extname(chunkInfo.facadeModuleId!))
const saveArr = ['content', 'service-worker']
return `[name]/${saveArr.includes(baseName) ? baseName : chunkInfo.name}.js`;
},
name: '[name].js'
}
},
},
})