-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: dependency package version upgrade
- Loading branch information
d3george
authored and
d3george
committed
Oct 18, 2024
1 parent
f32d07c
commit e0b3a18
Showing
8 changed files
with
1,251 additions
and
904 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
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'], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); |