44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { resolve } from 'path'
|
|
import viteImagemin from 'vite-plugin-imagemin'
|
|
import compression from 'vite-plugin-compression'
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
// 图片压缩:JPG→mozjpeg, PNG→pngquant
|
|
viteImagemin({
|
|
gifsicle: { optimizationLevel: 7 },
|
|
optipng: { optimizationLevel: 7 },
|
|
mozjpeg: { quality: 75 },
|
|
pngquant: { quality: [0.65, 0.8], speed: 4 },
|
|
svgo: {
|
|
plugins: [
|
|
{ name: 'removeViewBox' },
|
|
{ name: 'removeEmptyAttrs', active: false },
|
|
],
|
|
},
|
|
}),
|
|
// 生成 .gz 预压缩文件(Nginx 直接用,零延迟)
|
|
compression({ algorithm: 'gzip', ext: '.gz' }),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8000',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {},
|
|
},
|
|
})
|