-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
49 lines (45 loc) · 1.4 KB
/
Copy pathvite.config.ts
File metadata and controls
49 lines (45 loc) · 1.4 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
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { copyFileSync, mkdirSync } from 'fs';
export default defineConfig({
build: {
outDir: 'dist',
rollupOptions: {
input: {
'background/index': resolve(__dirname, 'src/background/index.ts'),
'content/index': resolve(__dirname, 'src/content/index.ts'),
'popup/popup': resolve(__dirname, 'src/popup/popup.ts'),
},
output: {
entryFileNames: '[name].js',
chunkFileNames: 'chunks/[name]-[hash].js',
format: 'es',
},
},
emptyOutDir: true,
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
plugins: [
{
name: 'copy-files',
closeBundle() {
mkdirSync('dist', { recursive: true });
mkdirSync('dist/popup', { recursive: true });
mkdirSync('dist/icons', { recursive: true });
// Copy manifest
copyFileSync('manifest.json', 'dist/manifest.json');
// Copy popup HTML and CSS
copyFileSync('src/popup/popup.html', 'dist/popup/popup.html');
copyFileSync('src/popup/popup.css', 'dist/popup/popup.css');
// Copy icons
copyFileSync('icons/icon16.png', 'dist/icons/icon16.png');
copyFileSync('icons/icon48.png', 'dist/icons/icon48.png');
copyFileSync('icons/icon128.png', 'dist/icons/icon128.png');
},
},
],
});