-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'd3george:main' into main
- Loading branch information
Showing
14 changed files
with
1,268 additions
and
918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
VITE_APP_BASE_API=/api | ||
VITE_APP_HOMEPAGE=/dashboard/workbench | ||
VITE_APP_BASE_PATH=/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
VITE_APP_BASE_API=/api | ||
VITE_APP_HOMEPAGE=/dashboard/workbench | ||
VITE_APP_BASE_PATH=/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,69 @@ | ||
import path from 'path'; | ||
|
||
import react from '@vitejs/plugin-react'; | ||
import { defineConfig } from 'vite'; | ||
import { visualizer } from 'rollup-plugin-visualizer'; | ||
import { defineConfig, loadEnv } from 'vite'; | ||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; | ||
import tsconfigPaths from 'vite-tsconfig-paths'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
base: './', | ||
esbuild: { | ||
// drop: ['console', 'debugger'], | ||
}, | ||
css: { | ||
// 开css sourcemap方便找css | ||
devSourcemap: true, | ||
}, | ||
plugins: [ | ||
react(), | ||
// 同步tsconfig.json的path设置alias | ||
tsconfigPaths(), | ||
createSvgIconsPlugin({ | ||
// 指定需要缓存的图标文件夹 | ||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], | ||
// 指定symbolId格式 | ||
symbolId: 'icon-[dir]-[name]', | ||
}), | ||
], | ||
server: { | ||
// 自动打开浏览器 | ||
open: true, | ||
host: true, | ||
port: 3001, | ||
proxy: { | ||
'/api': { | ||
target: 'http://localhost:3000', | ||
changeOrigin: true, | ||
rewrite: (path) => path.replace(/^\/api/, ''), | ||
export default defineConfig(({ mode }) => { | ||
const env = loadEnv(mode, process.cwd(), ''); | ||
const base = env.VITE_APP_BASE_PATH || '/'; | ||
const isProduction = mode === 'production'; | ||
|
||
return { | ||
base, | ||
plugins: [ | ||
react(), | ||
tsconfigPaths(), | ||
createSvgIconsPlugin({ | ||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], | ||
symbolId: 'icon-[dir]-[name]', | ||
}), | ||
isProduction && | ||
visualizer({ | ||
open: true, | ||
gzipSize: true, | ||
brotliSize: true, | ||
}), | ||
], | ||
server: { | ||
open: true, | ||
host: true, | ||
port: 3001, | ||
proxy: { | ||
'/api': { | ||
target: 'http://localhost:3000', | ||
changeOrigin: true, | ||
rewrite: (path) => path.replace(/^\/api/, ''), | ||
}, | ||
}, | ||
}, | ||
}, | ||
build: { | ||
target: 'esnext', | ||
minify: 'terser', | ||
terserOptions: { | ||
compress: { | ||
// 生产环境移除console | ||
drop_console: true, | ||
drop_debugger: true, | ||
optimizeDeps: { | ||
include: ['react', 'react-dom', 'react-router-dom', 'antd'], | ||
}, | ||
esbuild: { | ||
drop: isProduction ? ['console', 'debugger'] : [], | ||
}, | ||
build: { | ||
target: 'esnext', | ||
minify: 'esbuild', | ||
sourcemap: false, | ||
cssCodeSplit: true, | ||
chunkSizeWarningLimit: 1000, // 提高警告阈值到 1000 KB | ||
|
||
rollupOptions: { | ||
output: { | ||
manualChunks: { | ||
'vendor-react': ['react', 'react-dom', 'react-router-dom'], | ||
'vendor-antd': ['antd', '@ant-design/icons', '@ant-design/cssinjs'], | ||
'vendor-charts': ['apexcharts', 'react-apexcharts'], | ||
'vendor-utils': ['axios', 'dayjs', 'i18next', 'zustand'], | ||
'vendor-ui': ['framer-motion', 'styled-components', '@iconify/react'], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); |