- Added support for optimized image processing via `vite-plugin-imagemin`. - Configured build optimizations: set `terser` for JS minification and `lightningcss` for CSS. - Updated `.yarnrc` settings and cleaned dependencies in `yarn.lock`. - Disabled ESLint in `auto-imports.d.ts`.
123 lines
2.7 KiB
TypeScript
123 lines
2.7 KiB
TypeScript
// Plugins
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import Vue from '@vitejs/plugin-vue'
|
|
import { visualizer } from 'rollup-plugin-visualizer'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import Fonts from 'unplugin-fonts/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import VueRouter from 'unplugin-vue-router/vite'
|
|
import { defineConfig } from 'vite'
|
|
import Layouts from 'vite-plugin-vue-layouts'
|
|
import viteImagemin from 'vite-plugin-imagemin'
|
|
import Vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
|
|
|
|
// Utilities
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
VueRouter({
|
|
dts: 'src/typed-router.d.ts',
|
|
}),
|
|
Layouts({
|
|
layoutsDirs: 'src/layouts',
|
|
pagesDirs: 'src/pages',
|
|
defaultLayout: 'default',
|
|
}),
|
|
AutoImport({
|
|
imports: [
|
|
'vue',
|
|
{
|
|
'vue-router/auto': ['useRoute', 'useRouter'],
|
|
},
|
|
],
|
|
dts: 'src/auto-imports.d.ts',
|
|
eslintrc: {
|
|
enabled: true,
|
|
},
|
|
vueTemplate: true,
|
|
}),
|
|
Components({
|
|
dts: 'src/components.d.ts',
|
|
}),
|
|
Vue({
|
|
template: { transformAssetUrls },
|
|
}),
|
|
// https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin#readme
|
|
Vuetify({
|
|
autoImport: true,
|
|
styles: {
|
|
configFile: 'src/styles/settings.scss',
|
|
},
|
|
}),
|
|
Fonts({
|
|
google: {
|
|
families: [
|
|
{
|
|
name: 'Roboto',
|
|
styles: 'wght@100;300;400;500;700;900',
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
viteImagemin({
|
|
gifsicle: {
|
|
interlaced: true,
|
|
optimizationLevel: 3,
|
|
},
|
|
mozjpeg: {
|
|
quality: 80,
|
|
progressive: true,
|
|
},
|
|
optipng: {
|
|
optimizationLevel: 5,
|
|
},
|
|
pngquant: {
|
|
quality: [0.65, 0.8],
|
|
speed: 4,
|
|
},
|
|
svgo: {
|
|
plugins: [
|
|
{ name: 'removeViewBox', active: false },
|
|
{ name: 'removeEmptyAttrs', active: true },
|
|
],
|
|
},
|
|
webp: {
|
|
quality: 80,
|
|
},
|
|
}),
|
|
// Bundle analyzer - only run in analyze mode
|
|
process.env.ANALYZE &&
|
|
visualizer({
|
|
filename: 'dist/stats.html',
|
|
open: true,
|
|
brotliSize: true,
|
|
gzipSize: true,
|
|
}),
|
|
].filter(Boolean),
|
|
define: { 'process.env': {} },
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
extensions: ['.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
|
|
},
|
|
build: {
|
|
minify: 'terser',
|
|
cssMinify: 'lightningcss',
|
|
terserOptions: {
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
},
|
|
format: {
|
|
comments: false,
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
},
|
|
})
|