|
|
@@ -3,10 +3,37 @@ import type { PluginOption } from 'vite'
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
+import viteImagemin from 'vite-plugin-imagemin'
|
|
|
|
|
|
function setupPlugins(env: ImportMetaEnv): PluginOption[] {
|
|
|
return [
|
|
|
vue(),
|
|
|
+ viteImagemin({
|
|
|
+ gifsicle: {
|
|
|
+ optimizationLevel: 7,
|
|
|
+ interlaced: false
|
|
|
+ },
|
|
|
+ optipng: false,
|
|
|
+ mozjpeg: {
|
|
|
+ quality: 80
|
|
|
+ },
|
|
|
+ pngquant: {
|
|
|
+ quality: [0.5, 0.9],
|
|
|
+ speed: 1
|
|
|
+ },
|
|
|
+ svgo: {
|
|
|
+ plugins: [
|
|
|
+ {
|
|
|
+ name: 'removeViewBox'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'removeEmptyAttrs',
|
|
|
+ active: false
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ webp: false
|
|
|
+ }),
|
|
|
env.VITE_GLOB_APP_PWA === 'true' &&
|
|
|
VitePWA({
|
|
|
injectRegister: 'auto',
|