-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
45 lines (43 loc) · 1.36 KB
/
Copy pathvite.config.ts
File metadata and controls
45 lines (43 loc) · 1.36 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'node:path';
import { copyFileSync, mkdirSync, existsSync } from 'node:fs';
const root = __dirname;
export default defineConfig({
plugins: [
react(),
{
name: 'dodo-copy-manifest',
apply: 'build',
closeBundle() {
const outDir = resolve(root, 'dist');
if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true });
copyFileSync(resolve(root, 'public/manifest.json'), resolve(outDir, 'manifest.json'));
},
},
],
build: {
outDir: 'dist',
emptyOutDir: true,
rollupOptions: {
input: {
sidepanel: resolve(root, 'src/sidepanel/index.html'),
onboarding: resolve(root, 'src/onboarding/index.html'),
background: resolve(root, 'src/background/service-worker.ts'),
content: resolve(root, 'src/content/content.ts'),
},
output: {
entryFileNames: (chunk) => {
if (chunk.name === 'background') return 'background/service-worker.js';
if (chunk.name === 'content') return 'content/content.js';
return 'assets/[name]-[hash].js';
},
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]',
},
},
target: 'esnext',
minify: false,
sourcemap: true,
},
});