9 Star 40 Fork 35

Orginone/oiocns-react-bak

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 3.85 KB
一键复制 编辑 原始数据 按行查看 历史
认错人了 提交于 2024-05-21 19:37 . fix: 细节修复
import dayjs from 'dayjs';
import path from 'path';
import type { ConfigEnv, UserConfig } from 'vite';
import { themeVariables } from './config/theme';
import { createVitePlugins } from './config/vite/plugins';
import pkg from './package.json';
const { dependencies, devDependencies, name, version } = pkg;
const __APP_INFO__ = {
pkg: { dependencies, devDependencies, name, version },
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
};
// 函数式配置
export default ({ command, mode }: ConfigEnv): UserConfig => {
const isBuild = command === 'build';
return {
base: '/',
plugins: createVitePlugins(mode, isBuild),
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
modifyVars: themeVariables,
},
},
},
resolve: {
alias: [
{ find: /^~/, replacement: '' },
{ find: '@', replacement: path.resolve(__dirname, 'src') },
{ find: '@cfg', replacement: path.resolve(__dirname, 'config') },
],
},
server: {
// 是否主动唤醒浏览器
open: false,
// 占用端口 开发环境启动的端口
port: 8080,
// 是否使用https请求
// https: true,
// 扩展访问端口
host: true,
hmr: true,
watch: {
usePolling: true, // WSL必须,否则热更新无效
},
proxy: {
'/orginone': {
target: 'https://asset.orginone.cn', // 后台接口
changeOrigin: true, // 是否允许跨域
ws: true,
},
},
},
build: {
outDir: 'dist', // 指定输出路径
minify: 'terser', // 混淆器,terser构建后文件体积更小
sourcemap: false, // 输出.map文件
chunkSizeWarningLimit: 2048,
terserOptions: {
compress: {
drop_debugger: true, // 生产环境移除debugger
},
output: {
// 去掉注释内容
comments: true,
},
},
rollupOptions: {
treeshake: false,
external: ['handsontable'],
output: {
chunkFileNames: 'static/js/[hash].js',
entryFileNames: 'static/js/[hash].js',
assetFileNames: 'static/[ext]/[hash].[ext]',
manualChunks: {
'react-vendor': [
'react',
'react-use',
'react-dom',
'react-icons',
'qrcode.react',
'react-router-dom',
'react-office-viewer',
'react-router-config',
],
'antv-vendor': [
'@antv/x6',
'@antv/x6-plugin-dnd',
'@antv/x6-react-shape',
'@antv/x6-plugin-selection',
],
'editor-vendor': [
'for-editor',
'html2canvas',
'@wangeditor/editor',
'@wangeditor/editor-for-react',
],
'xlsx-vendor': ['xlsx'],
'play-vendor': ['jol-player'],
'dev-vendor': ['devextreme-react'],
'emoji-vendor': ['@emoji-mart/react', '@emoji-mart/data', 'emoji-mart'],
'antd-vendor': ['antd', '@ant-design/icons', '@ant-design/pro-components'],
},
},
plugins: [
{
name: 'no-treeshake',
transform(_, id) {
if (id.includes('integration/jquery')) {
return { moduleSideEffects: 'no-treeshake' };
}
if (id.includes('ui/data_grid')) {
return { moduleSideEffects: 'no-treeshake' };
}
},
},
],
},
},
define: {
// 设置应用信息
__APP_INFO__: JSON.stringify(__APP_INFO__),
// HACK: vite不会处理任何依赖中所需的补丁,例如@babel/types
'process.env': {
NODE_ENV: 'production',
},
// Buffer,
},
};
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/orginone/oiocns-react-bak.git
git@gitee.com:orginone/oiocns-react-bak.git
orginone
oiocns-react-bak
oiocns-react-bak
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385