-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
79 lines (73 loc) · 2.06 KB
/
vite.config.ts
File metadata and controls
79 lines (73 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
74
75
76
77
78
79
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { copyFileSync, mkdirSync, existsSync } from 'fs';
export default defineConfig({
build: {
outDir: 'dist',
emptyOutDir: true,
rollupOptions: {
input: {
background: resolve(__dirname, 'src/background.ts'),
'content-script': resolve(__dirname, 'src/content-script.ts'),
popup: resolve(__dirname, 'src/popup.ts'),
},
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name].[ext]',
format: 'es',
},
},
target: 'es2022',
minify: false, // Keep readable for debugging
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
},
plugins: [
{
name: 'copy-extension-files',
writeBundle() {
// Copy manifest.json
copyFileSync(
resolve(__dirname, 'src/manifest.json'),
resolve(__dirname, 'dist/manifest.json')
);
// Copy popup.html
copyFileSync(
resolve(__dirname, 'src/popup.html'),
resolve(__dirname, 'dist/popup.html')
);
// Copy injected script
copyFileSync(
resolve(__dirname, 'src/injected-script.js'),
resolve(__dirname, 'dist/injected-script.js')
);
// Copy images directory
const imagesDir = resolve(__dirname, 'dist/images');
if (!existsSync(imagesDir)) {
mkdirSync(imagesDir, { recursive: true });
}
const imageFiles = [
'switch16.png',
'switch32.png',
'switch48.png',
'switch128.png',
'github-image.svg'
];
imageFiles.forEach(file => {
const srcPath = resolve(__dirname, 'src/images', file);
const destPath = resolve(__dirname, 'dist/images', file);
if (existsSync(srcPath)) {
copyFileSync(srcPath, destPath);
}
});
},
},
],
});