代码拉取完成,页面将自动刷新
import { defineConfig, loadEnv, UserConfig, ConfigEnv } from 'vite';
import { createProxyConfig, createPlugins, resolvePath } from './build';
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const envConfig = loadEnv(mode, process.cwd()) as unknown as ImportMetaEnv;
const { VITE_PORT, VITE_HOST, VITE_CLEAN_CONSOLE } = envConfig;
const isProduction = mode === 'production';
// 获取env配置
const proxy = createProxyConfig(envConfig);
const plugins = createPlugins(mode, envConfig);
return {
plugins,
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
additionalData: `@import "./src/styles/var.less";`,
},
},
},
resolve: {
alias: {
src: resolvePath('./src'),
},
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.less', '.css', '.html', '.md'],
},
server: {
host: VITE_HOST,
port: Number(VITE_PORT) || 3000,
open: true,
proxy,
},
build: {
chunkSizeWarningLimit: 2000,
rollupOptions: {
output: {
manualChunks: {
react: ['react', 'react-dom', 'react-router-dom'],
antd: ['antd', '@ant-design/happy-work-theme'],
},
},
},
minify: 'terser',
terserOptions: {
maxWorkers: 4,
compress: {
keep_infinity: true,
drop_console: VITE_CLEAN_CONSOLE,
dead_code: true,
},
},
},
define: {
__PRODUCTION__: isProduction,
},
};
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。