-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
59 lines (56 loc) · 1.49 KB
/
vite.config.ts
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
import { defineConfig, loadEnv } from 'vite';
import { visualizer } from 'rollup-plugin-visualizer';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import dts from 'vite-plugin-dts';
import tailwindcss from 'tailwindcss';
// https://vitejs.dev/config/
export default ({ mode }) => {
const isProduction = mode === 'production';
const devEnv = loadEnv(mode, process.cwd(), '');
const prodEnv = loadEnv(mode, process.cwd(), '');
return defineConfig({
build: {
rollupOptions: {
output: {
assetFileNames: (assetInfo) => {
let extType = assetInfo.name!.split('.').at(1) as string;
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) {
extType = 'img';
}
return `assets/${extType}/[name]-[hash][extname]`;
},
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
},
},
sourcemap: true,
emptyOutDir: true,
},
css: {
postcss: {
plugins: [tailwindcss],
},
},
define: {
'process.env': isProduction ? prodEnv : devEnv,
},
plugins: [
react(),
tsconfigPaths(),
dts(),
visualizer({
filename: './dist/report.html',
open: true,
brotliSize: true,
}),
],
server: {
host: true,
port: 3000,
},
resolve: {
alias: [{ find: '@', replacement: '/src' }],
},
});
};