12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import { defineConfig } 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'
- const time = new Date().getTime()
- // @ts-ignore
- const apiProxyVersion = 'local'
- // https://vitejs.dev/config/
- export default defineConfig({
- define: {
- 'process.env': process.env
- },
- plugins: [vue(), viteCompression(), VitePluginHtmlEnv(), visualizer(), createSvgIconsPlugin({
- // 指定需要缓存的图标文件夹
- iconDirs: [resolve(process.cwd(), 'src/assets/svg')],
- // 指定symbolId格式
- symbolId: 'icon-[dir]-[name]',
- }), topLevelAwait({
- promiseExportName: '__tla',
- promiseImportName: i => `__tla_${i}`
- })],
- base: '/',
- resolve: {
- alias: {
- '@': resolve(__dirname, 'src'),
- '~@': resolve(__dirname, 'src'),
- '@views': resolve(__dirname, 'src/views'),
- '@components': resolve(__dirname, 'src/components')
- },
- },
- server: {
- port: 8686,
- // open: true,
- https: false,
- host: '0.0.0.0',
- strictPort: false,
- proxy: {
- '/api-ztpt/': {
- target: 'http://127.0.0.1:3001/',
- // target: 'http://10.110.35.47/',
- changeOrigin: true,
- rewrite: path => {
- return path.replace(/^\/api-ztpt/, '')
- }
- },
- '/api/': {
- target: 'http://8.140.240.182:18091/',
- changeOrigin: true,
- rewrite: path => {
- return path.replace(/^\/api/, '')
- }
- },
- }
- },
- build: {
- outDir: "duty",
- 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();
- }
- // if(id.indexOf('node_modules') > -1) {
- // return 'vendor'
- // }
- }
- }
- }
- },
- publicDir: 'src/out',
- optimizeDeps: {
- include: []
- }
- })
|