forked from ComposioHQ/open-chatgpt-atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
73 lines (66 loc) · 2.06 KB
/
vite.config.ts
File metadata and controls
73 lines (66 loc) · 2.06 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'node:url';
import { copyFileSync, mkdirSync, existsSync, readdirSync } from 'node:fs';
const __dirname = dirname(fileURLToPath(import.meta.url));
export default defineConfig({
plugins: [
react(),
{
name: 'copy-manifest',
closeBundle() {
// Copy manifest.json to dist
copyFileSync(
resolve(__dirname, 'manifest.json'),
resolve(__dirname, 'dist/manifest.json')
);
// Copy icons folder
const iconsDir = resolve(__dirname, 'icons');
const distIconsDir = resolve(__dirname, 'dist/icons');
if (existsSync(iconsDir)) {
if (!existsSync(distIconsDir)) {
mkdirSync(distIconsDir, { recursive: true });
}
// Copy all PNG icons
const iconFiles = readdirSync(iconsDir).filter((f: string) => f.endsWith('.png'));
iconFiles.forEach((file: string) => {
copyFileSync(
resolve(iconsDir, file),
resolve(distIconsDir, file)
);
});
console.log('✓ Copied manifest.json and icons to dist/');
} else {
console.log('✓ Copied manifest.json to dist/');
}
}
}
],
build: {
rollupOptions: {
input: {
sidepanel: resolve(__dirname, 'sidepanel.html'),
settings: resolve(__dirname, 'settings.html'),
background: resolve(__dirname, 'background.ts'),
content: resolve(__dirname, 'content.ts'),
},
output: {
entryFileNames: (chunkInfo) => {
// Content and background scripts should be standalone
return '[name].js';
},
chunkFileNames: 'chunks/[name]-[hash].js',
assetFileNames: '[name].[ext]',
},
},
outDir: 'dist',
emptyOutDir: true,
minify: false, // Don't minify to avoid single-line issues with Chrome
},
resolve: {
alias: {
'@': resolve(__dirname, './'),
},
},
});