-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
84 lines (69 loc) · 2.48 KB
/
Copy pathvite.config.ts
File metadata and controls
84 lines (69 loc) · 2.48 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { defineConfig } from 'vite';
import { resolve } from 'path';
export default defineConfig({
build: {
// Output to chrome-extension directory
outDir: 'chrome-extension',
emptyOutDir: false, // Don't delete manifest.json and other static files
rollupOptions: {
input: {
// Background service worker
background: resolve(__dirname, 'src/background/index.ts'),
// Content script (runs on main libbyapp.com page)
content: resolve(__dirname, 'src/content/index.ts'),
// Iframe extractor (runs in MAIN world)
'iframe-extractor': resolve(__dirname, 'src/iframe/extractor.ts'),
// Iframe UI injector
'iframe-ui': resolve(__dirname, 'src/iframe/ui-injector.ts'),
// Content script styles
'content-styles': resolve(__dirname, 'src/styles/content.css'),
},
output: {
// Output each entry to its own directory
entryFileNames: (chunkInfo) => {
const name = chunkInfo.name;
if (name === 'background') {
return 'background/[name].js';
}
if (name === 'content') {
return 'content/[name].js';
}
if (name === 'content-styles') {
return 'styles/[name].js';
}
if (name.startsWith('iframe')) {
return 'iframe/[name].js';
}
return '[name].js';
},
assetFileNames: (assetInfo) => {
if (assetInfo.name && assetInfo.name.endsWith('.css')) {
return 'styles/[name][extname]';
}
return 'assets/[name][extname]';
},
// Use ES modules format (required for code splitting with multiple inputs)
format: 'es',
// Allow code splitting to create shared chunks
manualChunks: undefined,
},
// Preserve module directives to avoid issues
preserveEntrySignatures: 'strict',
},
// Generate source maps for debugging (disabled in production for smaller builds)
sourcemap: false,
// Minify for production (reduces bundle size significantly)
minify: 'esbuild',
// Target modern browsers (Chrome extensions require modern Chrome anyway)
target: 'esnext',
// Additional optimizations
reportCompressedSize: true,
chunkSizeWarningLimit: 500, // Warn if chunks exceed 500kb (increased since we're inlining everything)
},
// Resolve TypeScript paths
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
});