90 lines
2.4 KiB
JavaScript
90 lines
2.4 KiB
JavaScript
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
|
|
import { createHtmlPlugin } from 'vite-plugin-html'
|
|
import viteCompression from 'vite-plugin-compression'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
// eslint-disable-next-line no-undef
|
|
const env = loadEnv(mode, process.cwd())
|
|
|
|
return {
|
|
base: './',
|
|
build: {
|
|
emptyOutDir: true,
|
|
manifest: true,
|
|
outDir: '../src/main/resources/static/manager-ui',
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (id.includes('node_modules')) {
|
|
if (id.includes('ant-design-vue')) {
|
|
return 'ant-design-vue'
|
|
} else if (id.includes('dayjs')) {
|
|
return 'dayjs'
|
|
} else if (id.includes('lodash')) {
|
|
return 'lodash'
|
|
} else if (id.includes('tree-lodash')) {
|
|
return 'tree-lodash'
|
|
} else if (id.includes('vue-request')) {
|
|
return 'vue-request'
|
|
} else if (id.includes('js-cookie')) {
|
|
return 'js-cookie'
|
|
} else if (id.includes('jsencrypt')) {
|
|
return 'jsencrypt'
|
|
} else if (id.includes('jwt-decode')) {
|
|
return 'jwt-decode'
|
|
} else {
|
|
return 'vendor'
|
|
}
|
|
} else {
|
|
return undefined
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
viteCompression({ threshold: 1024 * 300 }),
|
|
vueDevTools(),
|
|
Components({
|
|
resolvers: [
|
|
AntDesignVueResolver({
|
|
importStyle: false, // css in js
|
|
}),
|
|
],
|
|
}),
|
|
createHtmlPlugin({
|
|
inject: {
|
|
data: {
|
|
VITE_APP_TITLE: env.VITE_APP_TITLE,
|
|
},
|
|
},
|
|
}),
|
|
],
|
|
server: {
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
}
|
|
})
|