-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
50 lines (44 loc) · 1.21 KB
/
vite.config.js
File metadata and controls
50 lines (44 loc) · 1.21 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
import { defineConfig } from 'vite';
import importMetaUrlPlugin from '@codingame/esbuild-import-meta-url-plugin';
export default defineConfig({
worker: {
format: 'es'
},
build: {
outDir: '../shadowcode',
emptyOutDir: true,
target: 'esnext',
minify: 'esbuild',
cssMinify: 'esbuild',
reportCompressedSize: false,
rollupOptions: {
input: 'src/index.html'
}
},
optimizeDeps: {
esbuildOptions: {
plugins: [importMetaUrlPlugin]
}
},
plugins: [
{
generateBundle(_, bundle) {
for (const [fileName, asset] of Object.entries(bundle)) {
if (!fileName.endsWith('.html')) continue;
let sourceText = null;
if (typeof asset?.source === 'string') {
sourceText = asset.source;
} else if (asset?.source instanceof Uint8Array) {
sourceText = Buffer.from(asset.source).toString('utf8');
}
if (typeof sourceText !== 'string') continue;
sourceText = sourceText.replace(
/<meta[^>]*Content-Security-Policy[^>]*>/gi,
''
);
asset.source = sourceText;
}
}
}
]
});