-
Notifications
You must be signed in to change notification settings - Fork 7
/
vite.config.content.ts
49 lines (38 loc) · 1.29 KB
/
vite.config.content.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
// TypeScript allows us to safely import JSON with assertion
import packageJson from './package.json' assert { type: 'json' }
import { defineConfig, Plugin, ResolvedConfig, BuildOptions } from 'vite'
import { isDev, r } from './scripts/utility'
import react from '@vitejs/plugin-react'
import path from 'path'
const { name }: { name: string } = packageJson
console.info(' ---> Starting Content Script Build 🤞 <---')
const config = defineConfig({
plugins: [react()],
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }]
},
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
},
build: {
watch: {
include: ['./src/**/*']
},
outDir: r('dist/js'),
cssCodeSplit: false,
emptyOutDir: false,
sourcemap: isDev ? 'inline' : false,
lib: {
entry: r('src/scripts/content/index.tsx'),
name: name,
formats: ['iife'] // Bundle everything together so chrome.runtime is available in our React app/components.
},
rollupOptions: {
output: {
entryFileNames: 'content.js',
extend: true
}
}
} as BuildOptions
})
export default config