-
Notifications
You must be signed in to change notification settings - Fork 161
/
vite.config.js
37 lines (34 loc) · 1.1 KB
/
vite.config.js
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
import fs from 'node:fs';
import { defineConfig } from 'vite';
import { viteSingleFile } from 'vite-plugin-singlefile';
import pluginDom from 'vite-plugin-dom';
import { DomUtils } from 'htmlparser2';
const removeNodes = [ 'rowExamples' ];
const preventSVGEmit = () => {
return {
generateBundle(opts, bundle) {
for (const key in bundle)
if (key.endsWith('.svg'))
delete bundle[key];
},
};
};
export default defineConfig({
plugins: [
preventSVGEmit(),
pluginDom({
applyOnMode: true, // all modes
handler: node => {
if (removeNodes.includes(node.attribs.id))
DomUtils.removeElement(node);
else if (node.name == 'link' && node.attribs.rel == 'icon')
node.attribs.href = 'data:image/svg xml;base64,' btoa(fs.readFileSync('favicon.svg', 'ascii').replace(/^([^<] |<[^s]|<s[^v]|<sv[^g]) /, '').trim());
},
}),
viteSingleFile(),
],
build: {
minify: false,
cssMinify: false,
},
});