mirror of
https://gitee.com/bootx/dax-pay-ui.git
synced 2025-09-08 05:08:03 +00:00
chore: add some notes
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import type { UserConfig, ConfigEnv } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import legacy from '@vitejs/plugin-legacy';
|
||||
|
||||
import { loadEnv } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import { generateModifyVars } from './build/config/themeConfig';
|
||||
import { createProxy } from './build/vite/proxy';
|
||||
@@ -18,11 +15,14 @@ function pathResolve(dir: string) {
|
||||
return resolve(__dirname, '.', dir);
|
||||
}
|
||||
|
||||
const root = process.cwd();
|
||||
|
||||
export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
const root = process.cwd();
|
||||
|
||||
const env = loadEnv(mode, root);
|
||||
|
||||
// The boolean type read by loadEnv is a string. This function can be converted to boolean type
|
||||
const viteEnv = wrapperEnv(env);
|
||||
|
||||
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE, VITE_LEGACY } = viteEnv;
|
||||
|
||||
const isBuild = command === 'build';
|
||||
@@ -32,12 +32,14 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
root,
|
||||
alias: [
|
||||
{
|
||||
// /@/xxxx => src/xxx
|
||||
find: /^\/@\//,
|
||||
replacement: pathResolve('src') + '/',
|
||||
},
|
||||
],
|
||||
server: {
|
||||
port: VITE_PORT,
|
||||
// Load proxy configuration from .env
|
||||
proxy: createProxy(VITE_PROXY),
|
||||
hmr: {
|
||||
overlay: true,
|
||||
@@ -50,9 +52,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
terserOptions: {
|
||||
compress: {
|
||||
keep_infinity: true,
|
||||
// Used to delete console in production environment
|
||||
drop_console: VITE_DROP_CONSOLE,
|
||||
},
|
||||
},
|
||||
// Turning off brotliSize display can slightly reduce packaging time
|
||||
brotliSize: false,
|
||||
chunkSizeWarningLimit: 1200,
|
||||
},
|
||||
@@ -68,6 +72,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
preprocessorOptions: {
|
||||
less: {
|
||||
modifyVars: {
|
||||
// Used for global import to avoid the need to import each style file separately
|
||||
// reference: Avoid repeated references
|
||||
hack: `true; @import (reference) "${resolve('src/design/config.less')}";`,
|
||||
...generateModifyVars(),
|
||||
@@ -77,14 +82,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
},
|
||||
},
|
||||
|
||||
plugins: [
|
||||
vue(),
|
||||
vueJsx(),
|
||||
...(VITE_LEGACY && isBuild ? [legacy()] : []),
|
||||
...createVitePlugins(viteEnv, isBuild),
|
||||
],
|
||||
// The vite plugin used by the project. The quantity is large, so it is separately extracted and managed
|
||||
plugins: createVitePlugins(viteEnv, isBuild),
|
||||
|
||||
optimizeDeps: {
|
||||
// @iconify/iconify: The dependency is dynamically and virtually loaded by @purge-icons/generated, so it needs to be specified explicitly
|
||||
include: ['@iconify/iconify'],
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user