12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import { defineConfig, loadEnv } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import topLevelAwait from 'vite-plugin-top-level-await'
- import { resolve } from 'path'
- import viteCompression from 'vite-plugin-compression' //Gzip
- import { visualizer } from 'rollup-plugin-visualizer'
- import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' // 【svg-icons相关】
- import VitePluginHtmlEnv from 'vite-plugin-html-env'
- // @ts-ignore
- import tailwindcss from '@tailwindcss/vite'
- const time = new Date().getTime()
- export default defineConfig(({ mode, command }) => {
- const env = loadEnv(mode, process.cwd())
- const { VITE_BASE } = env
- return {
- define: {
- 'process.env': process.env,
- },
- plugins: [
- vue(),
- viteCompression(),
- VitePluginHtmlEnv(),
- tailwindcss(),
- visualizer(),
- createSvgIconsPlugin({
- // 指定需要缓存的图标文件夹
- iconDirs: [resolve(process.cwd(), 'src/assets/svg')],
- // 指定symbolId格式
- symbolId: 'icon-[dir]-[name]',
- // svgoOptions: {
- // plugins: [
- // {
- // name: 'removeAttrs',
- // params: {
- // attrs: ['class', 'data-name', 'fill', 'stroke']
- // }
- // }
- // ]
- // }
- }),
- topLevelAwait({
- promiseExportName: '__tla',
- promiseImportName: (i) => `__tla_${i}`,
- }),
- ],
- base: '/' + VITE_BASE + '/',
- resolve: {
- alias: {
- '@': resolve(__dirname, 'src'),
- },
- },
- server: {
- port: 9757,
- host: '0.0.0.0',
- open: true,
- strictPort: false,
- proxy: {
- [env.VITE_BASE_API_PROXY]: {
- target: 'http://1.95.78.201:18088/',
- changeOrigin: true,
- rewrite: (path) => path.replace(env.VITE_BASE_API_PROXY, ''),
- },
- [env.VITE_WORKFLOW_API_PROXY]: {
- target: 'http://1.95.78.201:18087/',
- changeOrigin: true,
- rewrite: (path) => path.replace(env.VITE_WORKFLOW_API_PROXY, ''),
- },
- },
- },
- build: {
- target: 'esnext',
- sourcemap: false,
- outDir: env.VITE_BASE,
- rollupOptions: {
- //分包优化
- output: {
- manualChunks(id) {
- if (id.includes('node_modules')) {
- return (
- time +
- id.toString().split('node_modules/')[1].split('/')[0].toString()
- )
- } else {
- return time + id.toString()
- }
- },
- },
- },
- },
- publicDir: 'src/out',
- optimizeDeps: {
- include: [],
- },
- } as any
- })
|