-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
67 lines (65 loc) · 2.05 KB
/
Copy pathvite.config.ts
File metadata and controls
67 lines (65 loc) · 2.05 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
56
57
58
59
60
61
62
63
64
65
66
67
import path from 'node:path';
import vue from '@vitejs/plugin-vue';
import autoprefixer from 'autoprefixer';
import tailwind from 'tailwindcss';
import UnoCSS from 'unocss/vite';
import Unfonts from 'unplugin-fonts/vite';
import Icons from 'unplugin-icons/vite';
import { defineConfig } from 'vite';
import removeConsole from 'vite-plugin-remove-console';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const isProd = mode === 'production'; // Adjust the condition as needed
return {
optimizeDeps: {
exclude: ['@electric-sql/pglite'],
},
build: {
target: 'esnext',
sourcemap: true,
},
css: {
postcss: {
plugins: [tailwind(), autoprefixer()],
},
},
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: tag => ['perspective-viewer', 'perspective-viewer-datagrid', 'perspective-viewer-d3fc'].includes(tag),
},
},
}),
UnoCSS(),
Unfonts({
google: {
preconnect: true,
families: ['Roboto Mono', 'Poppins', 'Inter'],
},
}),
Icons({
// experimental
autoInstall: true,
}),
{
name: 'html-transform',
transformIndexHtml(html) {
if (isProd) {
return html.replace(
'</head>',
`<script defer src="https://analytics.swninja.dev/script.js" data-website-id="918cc775-65fc-418c-be8c-8597cdd1a450"></script>\n</body>`,
);
}
return html;
},
},
removeConsole(),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
};
});