feat: 修改stystem-ui的页面打包
This commit is contained in:
		
							
								
								
									
										64
									
								
								apps/ui/config/rollup.components.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								apps/ui/config/rollup.components.config.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,64 @@ | ||||
| import resolve from '@rollup/plugin-node-resolve'; | ||||
| import typescript from '@rollup/plugin-typescript'; | ||||
| import commonjs from '@rollup/plugin-commonjs'; | ||||
| import postcss from 'rollup-plugin-postcss'; | ||||
| import autoprefixer from 'autoprefixer'; | ||||
| import cssnano from 'cssnano'; | ||||
| import terser from '@rollup/plugin-terser'; | ||||
|  | ||||
| import postcssImport from 'postcss-import'; | ||||
| import dts from 'rollup-plugin-dts'; | ||||
|  | ||||
| import * as glob from 'glob'; | ||||
| import path from 'path'; | ||||
| const isApps = process.env.TYPE === 'apps'; | ||||
| const components = glob.sync('./src/components/**/index.ts'); | ||||
| const entrys = components.map((entry) => { | ||||
|   return entry; | ||||
| }); | ||||
| console.log('entry', entrys); | ||||
| const output = path.resolve('./dist'); | ||||
| console.log('output', output); | ||||
| /** | ||||
|  * @type {import('rollup').RollupOptions[]} | ||||
|  */ | ||||
| const configs = entrys | ||||
|   .map((entry) => { | ||||
|     const directory = path.dirname(entry); | ||||
|     const lastDirectory = directory.split('/').pop(); | ||||
|     const input = path.resolve(entry); | ||||
|     const buildConfig = { | ||||
|       input: input, // 修改输入文件为 TypeScript 文件 | ||||
|       output: { | ||||
|         file: path.join(output, `./${lastDirectory}.js`), | ||||
|         format: 'es', // 输出格式为 ES Module | ||||
|       }, | ||||
|       plugins: [ | ||||
|         resolve({ | ||||
|           browser: true, // 处理浏览器版本的依赖 | ||||
|         }), | ||||
|         commonjs(), | ||||
|         typescript({ | ||||
|           tsconfig: './tsconfig.json', | ||||
|           compilerOptions: { | ||||
|             declaration: false, // 生成声明文件 | ||||
|             declarationDir: './dist', // 声明文件输出目录 | ||||
|             // outDir: './types', // | ||||
|           }, | ||||
|         }), // 添加 TypeScript 插件 | ||||
|         // terser(), // 压缩输出的 ES Module 文件 | ||||
|       ], | ||||
|     }; | ||||
|     const tsConfig = { | ||||
|       input: input, | ||||
|       output: { | ||||
|         file: path.join(output, `./${lastDirectory}.d.ts`), | ||||
|         format: 'esm', | ||||
|       }, | ||||
|       plugins: [dts()], | ||||
|     }; | ||||
|     return [buildConfig, tsConfig]; | ||||
|   }) | ||||
|   .flat(); | ||||
|  | ||||
| export default [...configs]; | ||||
		Reference in New Issue
	
	Block a user