-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.content.config.js
40 lines (39 loc) · 1.02 KB
/
vite.content.config.js
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
import { defineConfig } from 'vite'
import path from 'path'
import react from '@vitejs/plugin-react'
// import { CRX_CONTENT_OUTDIR } from "./globalConfig"
import dotenv from 'dotenv'
dotenv.config()
export default defineConfig({
build: {
outDir: process.env.TEMP_CONTENT_DIR,
// https://cn.vitejs.dev/config/build-options.html#build-lib
lib: {
name: 'contentLib',
entry: path.resolve(__dirname, 'src/content/index.jsx'),
// content script不支持ES6,因此不用使用es模式,需要改为cjs模式
// formats: ["es", "cjs"],
fileName: () => {
return 'content.js'
},
},
rollupOptions: {
input: 'src/content/index.jsx',
output: {
assetFileNames: assetInfo => {
// 附属文件命名,content script会生成配套的css
return 'content.css'
},
},
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
define: {
'process.env.NODE_ENV': null,
},
plugins: [react()],
})