-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
83 lines (77 loc) · 2.63 KB
/
Copy pathvite.config.ts
File metadata and controls
83 lines (77 loc) · 2.63 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
import { defineConfig, build } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import { copyFileSync, mkdirSync, existsSync } from 'fs';
// Plugin to build content script separately and copy static files
function buildContentScript() {
return {
name: 'build-content-script',
async closeBundle() {
// Build content script separately with IIFE format
await build({
configFile: false,
build: {
outDir: 'dist',
emptyOutDir: false,
lib: {
entry: resolve(__dirname, 'src/content/index.ts'),
name: 'RePRoContent',
formats: ['iife'],
fileName: () => 'content.js',
},
rollupOptions: {
output: {
extend: true,
},
},
},
});
console.log('✓ Built content script');
// Copy static files
if (!existsSync('dist')) {
mkdirSync('dist', { recursive: true });
}
// Copy content.css
try {
copyFileSync('src/content/content.css', 'dist/content.css');
console.log('✓ Copied content.css');
} catch (e) {
console.error('Failed to copy content.css:', e);
}
// Copy manifest.json
try {
copyFileSync('manifest.json', 'dist/manifest.json');
console.log('✓ Copied manifest.json');
} catch (e) {
console.error('Failed to copy manifest.json:', e);
}
// Copy icons directory
if (!existsSync('dist/icons')) {
mkdirSync('dist/icons', { recursive: true });
}
try {
copyFileSync('public/icon.svg', 'dist/icons/icon.svg');
console.log('✓ Copied icon.svg');
} catch (e) {
console.error('Failed to copy icon.svg:', e);
}
}
};
}
export default defineConfig({
plugins: [react(), buildContentScript()],
base: './',
build: {
outDir: 'dist',
rollupOptions: {
input: {
popup: resolve(__dirname, 'src/popup/index.html'),
},
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name].[ext]',
},
},
},
});