-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.js
More file actions
78 lines (67 loc) · 1.8 KB
/
Copy pathbuild.js
File metadata and controls
78 lines (67 loc) · 1.8 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
```
yarn build core loading immer devtools
```
*/
const fs = require('fs-extra')
const path = require('path')
const chalk = require('chalk')
const execa = require('execa')
const args = require('minimist')(process.argv.slice(2))
const targets = args._
// const formats = args.formats || args.f
const devOnly = args.devOnly || args.d
// const prodOnly = !devOnly && (args.prodOnly || args.p)
// const buildAllMatching = args.all || args.a
// const lean = args.lean || args.l
// const commit = execa.sync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7)
run()
async function run() {
await buildAll(targets);
// if (!targets.length) {
// await buildAll(targets);
// // checkAllSizes(allTargets)
// }
// else {
// await buildAll(fuzzyMatchTarget(targets, buildAllMatching))
// checkAllSizes(fuzzyMatchTarget(targets, buildAllMatching))
// }
}
async function buildAll(targets) {
for (const target of targets) {
await build(target)
}
}
// async function buildAll() {
// await build('devtools');
// console.log(targets);
// }
async function build(target) {
const pkgDir = path.resolve(`packages/${target}`)
const pkg = require(`${pkgDir}/package.json`)
await fs.remove(`${pkgDir}/lib`)
await fs.remove(`${pkgDir}/es`)
await fs.remove(`${pkgDir}/dist`)
const env =
(pkg.buildOptions && pkg.buildOptions.env) ||
(devOnly ? 'development' : 'production')
await execa(
'rollup',
[
'-c',
'--environment',
[
// `COMMIT:${commit}`,
`NODE_ENV:${env}`,
`TARGET:${target}`,
// formats ? `FORMATS:${formats}` : ``,
// args.types ? `TYPES:true` : ``,
// prodOnly ? `PROD_ONLY:true` : ``,
// lean ? `LEAN:true` : ``
]
.filter(Boolean)
.join(',')
],
{ stdio: 'inherit' }
)
}