-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
161 lines (154 loc) · 3.9 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react-swc";
import { VitePWA } from "vite-plugin-pwa";
import legacy from "@vitejs/plugin-legacy";
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
import svgr from "vite-plugin-svgr";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
VitePWA({
srcDir: "./src",
// mode: 'development',
scope: "/",
base: "/",
devOptions: {
enabled: true
},
registerType: "autoUpdate",
injectRegister: "auto",
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
sourcemap: true
},
includeAssets: ['vite.svg', 'maskable_icon.png', 'robots.txt', 'vite.png'],
manifest: {
name: 'Ionic React Vite PWA',
short_name: 'IonicReactVitePWA',
description: 'A sprouting product of Joseph Godwin Kimani',
theme_color: '#ffffff',
//start_url: "/",
scope: "/",
icons: [
{
src: 'maskable_icon_x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'maskable_icon_x512.png',
sizes: '512x512',
type: 'image/png'
},
{
src: 'vite.svg',
sizes: '32x32',
type: 'image/svg'
}
]
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['../tests/setup.js'],
include: ['**/*(*.)?{test,spec}.{js,jsx,cjs,ts,mts,cts,tsxm,}'],
exclude: ['.vscode', 'node_modules', 'dist', '.idea', '.git', '.cache'],
},
}),
legacy({
targets: ['defaults', 'not IE 11'],
}),
svgr({
// Set it to `true` to export React component as default.
// Notice that it will overrides the default behavior of Vite.
exportAsDefault: false,
// svgr options: https://react-svgr.com/docs/options/
svgrOptions: {
// ...
},
// esbuild options, to transform jsx to js
esbuildOptions: {
// ...
},
// A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should include. By default all svg files will be included.
include: '**/*.svg',
// A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.
exclude: '',
}),
ViteImageOptimizer({
// Include all assets within the public directory defined in Vite. When true it will recursively traverse the directory and optimize all the assets.
includePublic: true,
// Logs the optimization stats to terminal output with file size difference in kB and percent increase/decrease.
logStats: true,
svg: {
multipass: true,
plugins: [
{
name: 'preset-default',
params: {
overrides: {
cleanupNumericValues: false,
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
},
cleanupIDs: {
minify: false,
remove: false,
},
convertPathData: false,
},
},
'sortAttrs',
{
name: 'addAttributesToSVGElement',
params: {
attributes: [{ xmlns: 'http://www.w3.org/2000/svg' }],
},
},
],
},
png: {
// https://sharp.pixelplumbing.com/api-output#png
quality: 100,
},
jpeg: {
// https://sharp.pixelplumbing.com/api-output#jpeg
quality: 100,
},
jpg: {
// https://sharp.pixelplumbing.com/api-output#jpeg
quality: 100,
},
tiff: {
// https://sharp.pixelplumbing.com/api-output#tiff
quality: 100,
},
// gif does not support lossless compression
// https://sharp.pixelplumbing.com/api-output#gif
gif: {},
webp: {
// https://sharp.pixelplumbing.com/api-output#webp
lossless: true,
},
avif: {
// https://sharp.pixelplumbing.com/api-output#avif
lossless: true,
},
}),
],
resolve: {
alias: [
{
find: /^~.+/,
replacement: (val) => {
return val.replace(/^~/, "");
}
}
]
},
build: {
commonjsOptions: {
transformMixedEsModules: true
}
}
});