UNPKG

create-tengits-app

Version:

🚀 快速创建基于 React + Rsbuild + TypeScript + Tailwind CSS + Antd 的现代前端项目脚手架

78 lines (76 loc) 2.13 kB
import path from 'node:path'; import { defineConfig, loadEnv } from '@rsbuild/core'; import { pluginReact } from '@rsbuild/plugin-react'; import { pluginSvgr } from '@rsbuild/plugin-svgr'; import { pluginLess } from '@rsbuild/plugin-less'; export default defineConfig(({ env, envMode }) => { const { publicVars, parsed } = loadEnv({ mode: envMode, prefixes: ['REACT_APP_', 'VITE_'] }); return { dev: { lazyCompilation: true, }, plugins: [ pluginReact(), pluginSvgr(), pluginLess(), ], html: { template: './index.html', templateParameters: { ...parsed, PROD: env === 'production', }, }, source: { define: { ...publicVars, 'import.meta.env': Object.entries(parsed).reduce((acc, [key, value]) => { acc[key] = JSON.stringify(value); return acc; }, {}), '__APP_ENV__': JSON.stringify({ BASE_URL: '' }), }, entry: { index: './src/index.jsx', }, }, resolve: { alias: { '@': path.resolve(__dirname, 'src'), }, dedupe: ['react', 'react-dom', 'react-query'], }, server: { port: 3000, proxy: [{ context: ['/tladapter', '/tlai', '/api', '/testuser', '/crud', '/ttos', '/saas', '/web', '/adapter', '/tlbi', '/sign'], target: parsed.VITE_REACT_APP_HOST, changeOrigin: true, ws: true, }], }, output: { legalComments: 'none', manifest: true, // 根据需要配置外部依赖 externals: { 'react': 'React', 'react-dom': 'ReactDOM', 'react-router-dom': 'ReactRouterDOM', 'dayjs': 'dayjs', 'antd': 'antd', 'tengits-ui5': 'tengitsui5' }, }, performance: { removeConsole: env === 'production' ? ['log'] : [], buildCache: true, chunkSplit: { strategy: 'split-by-experience', forceSplitting: { // 根据需要配置代码分割 }, }, }, }; });