forked from ant-design/pro-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateSizeLimit.js
36 lines (29 loc) · 955 Bytes
/
generateSizeLimit.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
33
34
35
36
const path = require('path');
const fs = require('fs');
const writePkg = require('write-pkg');
const cwd = process.cwd();
const ignoreDirPath = ['.DS_Store'];
const filePath = path.resolve(cwd, 'package.json');
const packagesDir = path.resolve(cwd, 'packages');
const json = JSON.parse(fs.readFileSync(filePath, 'utf8'));
delete json['size-limit'];
let componentsNames = fs.readdirSync(packagesDir);
componentsNames = componentsNames.filter((dir) => ignoreDirPath.indexOf(dir) === -1);
(async () => {
const sizeLimitConfig = [];
componentsNames.forEach((component) => {
sizeLimitConfig.push({
path: `packages/${component}/lib/**/*.js`,
limit: '2 s',
webpack: false,
running: false,
});
sizeLimitConfig.push({
path: `packages/${component}/es/**/*.js`,
limit: '2 s',
webpack: false,
running: false,
});
});
await writePkg(cwd, { ...json, 'size-limit': sizeLimitConfig });
})();