Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
55 lines (48 loc) · 1.61 KB
/
Copy pathvite.config.ts
File metadata and controls
55 lines (48 loc) · 1.61 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
/**
* Vite config for the ConsentTheater sidebar UI (Preact + Tailwind + shadcn).
*
* Background and content scripts are bundled separately by esbuild inside
* scripts/build.js — they don't fit Vite's UI-oriented pipeline (service worker
* + content script contexts, no HTML entry, single-file IIFE output needed).
*/
import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import tailwindcss from '@tailwindcss/vite';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const SHARED_OUT = path.resolve(__dirname, 'dist/.shared');
export default defineConfig({
plugins: [preact(), tailwindcss()],
// Relative asset paths so the built HTML works from chrome-extension://ID/ui/sidebar.html
base: './',
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
react: 'preact/compat',
'react-dom': 'preact/compat',
'react-dom/test-utils': 'preact/test-utils',
'react/jsx-runtime': 'preact/jsx-runtime'
}
},
root: path.resolve(__dirname, 'src/ui'),
build: {
outDir: path.resolve(SHARED_OUT, 'ui'),
emptyOutDir: true,
sourcemap: false,
target: 'es2022',
minify: 'esbuild',
rollupOptions: {
input: {
sidebar: path.resolve(__dirname, 'src/ui/index.html'),
report: path.resolve(__dirname, 'src/ui/report.html')
},
output: {
entryFileNames: 'assets/[name]-[hash].js',
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]'
}
}
},
server: { port: 5173 }
});