-
Notifications
You must be signed in to change notification settings - Fork 5
/
dev.build.js
32 lines (27 loc) · 933 Bytes
/
dev.build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* @Author: HxB
* @Date: 2024-05-11 11:04:49
* @LastEditors: DoubleAm
* @LastEditTime: 2024-05-11 17:45:23
* @Description: 转化开发相关内容并导出
* @FilePath: \js-xxx\dev.build.js
*/
const fs = require('fs');
const path = require('path');
const transferObj = require('./dev.config.js');
console.log('---转换 Dev 开始---');
let es6ModuleContent = '\n/* eslint-disable */\n// @ts-nocheck\n';
Object.keys(transferObj).forEach((i) => {
const val = transferObj[i];
const type = typeof val;
if (val === undefined) {
return;
}
console.log(`(${type}) export const ${i}`);
es6ModuleContent += `\nexport const ${i} = ${type === 'function' ? val.toString() : JSON.stringify(val, null, 2)};\n`;
});
// 输出到新文件
const outputFolder = './src/Dev/';
const outputPath = path.join(outputFolder, 'index.ts');
fs.writeFileSync(outputPath, es6ModuleContent);
console.log('---转换 Dev 完成---');