-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
84 lines (81 loc) · 1.87 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import * as path from 'node:path';
import react from '@vitejs/plugin-react-swc';
import { defineConfig } from 'vite';
import Printer from 'vite-host-qrcode/vite';
import checker from 'vite-plugin-checker';
import EnvironmentPlugin from 'vite-plugin-environment';
import ResizeImage from 'vite-plugin-resize-image/vite';
import webfontDownload from 'vite-plugin-webfont-dl';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const isDev = mode !== 'production';
const isAnalyze = mode === 'analyze';
return {
plugins: [
react(),
EnvironmentPlugin('all'),
checker({
typescript: true,
}),
Printer({
info: [
({ bold, cyan, green }) => {
return {
text: ` ${green('➜')} ${bold('Font Icon:')} ${bold(
cyan('http://localhost:4005/public/t4font/index.html'),
)}`,
};
},
],
}),
ResizeImage({
mode: 'sharp',
cache: true,
compress: {
jpg: {
quality: 70,
},
jpeg: {
quality: 70,
},
png: {
quality: 70,
},
webp: {
quality: 70,
},
},
conversion: [
{ from: 'jpeg', to: 'webp' },
{ from: 'png', to: 'webp' },
{ from: 'JPG', to: 'jpeg' },
],
}),
webfontDownload(),
],
css: {
devSourcemap: isDev,
},
optimizeDeps: {
include: ['react'],
},
build: {
commonjsOptions: {
include: [/node_modules/],
},
sourcemap: isAnalyze,
},
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
esbuild: {
sourcemap: isDev,
},
server: {
port: 4005,
},
preview: {
port: 4005,
},
};
});