create-ias-lowcode
Version:
39 lines (28 loc) • 1.46 kB
JavaScript
/**
* 此脚本用于构建指定的组件
* 使用方法: node scripts/esm-wrapper.js build-component [组件名称]
* 示例: node scripts/esm-wrapper.js build-component BaseButton,BaseInput
* 或使用 npm/pnpm 运行: pnpm build:components BaseButton,BaseInput
*/
const { execSync } = require('child_process');
const path = require('path');
const fs = require('fs');
// 获取命令行参数
const componentsArg = process.argv[2];
console.log('componentsArg', componentsArg);
// if (!componentsArg) {
// console.error('请指定要构建的组件名称,例如:node scripts/esm-wrapper.js build-component BaseButton');
// process.exit(1);
// }
execSync(`vite build -- --name ${componentsArg}`, { stdio: 'inherit', env: process.env });
// 生成 tsconfig.build.json
console.log(`正在为组件 ${componentsArg} 生成配置文件...`);
execSync(`node ${path.join(__dirname, 'generate-tsconfig-build.cjs')} ${componentsArg}`, { stdio: 'inherit' });
// 生成类型声明文件
console.log('正在生成类型声明文件...');
// 不使用-b选项,直接使用tsconfig.build.json配置
execSync('tsc --project tsconfig.build.json --skipLibCheck', { stdio: 'inherit' });
console.log('所有组件构建完成!');
console.log('开始上传文件...');
execSync(`node ${path.join(__dirname, 'upload-script.cjs')} ${componentsArg}`, { stdio: 'inherit' });
console.log('文件上传完成!');