-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathvite.injected.config.ts
More file actions
40 lines (36 loc) · 1004 Bytes
/
vite.injected.config.ts
File metadata and controls
40 lines (36 loc) · 1004 Bytes
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 'node:path'
const ENTRIES = {
'page-detector': 'src/injected/page-detector.ts',
'page-source-search': 'src/injected/page-source-search.ts'
} as const
type EntryName = keyof typeof ENTRIES
const entryName = (process.env.INJECTED_ENTRY ?? '') as EntryName
if (!ENTRIES[entryName]) {
throw new Error(`INJECTED_ENTRY must be one of: ${Object.keys(ENTRIES).join(', ')} (got "${entryName}")`)
}
export default defineConfig({
publicDir: false,
build: {
outDir: 'public/injected',
emptyOutDir: false,
minify: 'esbuild',
target: 'chrome120',
lib: {
entry: path.resolve(__dirname, ENTRIES[entryName]),
formats: ['iife'],
name: `__StackPrismInjected_${entryName.replace(/-/g, '_')}__`,
fileName: () => `${entryName}.iife.js`
},
rollupOptions: {
output: {
inlineDynamicImports: true
}
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
}
})