forked from aris-creator/jancok
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.js
50 lines (42 loc) · 1.19 KB
/
dev.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Run Rollup in watch mode for development.
To specific the package to watch, simply pass its name and the desired build
formats to watch (defaults to "global"):
```
# name supports fuzzy match. will watch all packages with name containing "dom"
yarn dev dom
# specify the format to output
yarn dev core --formats cjs
# Can also drop all __DEV__ blocks with:
__DEV__=false yarn dev
```
*/
const execa = require("execa");
const path = require("path");
const { fuzzyMatchTarget } = require("./utils");
const args = require("minimist")(process.argv.slice(2));
const target = args._.length
? fuzzyMatchTarget(args._)[0]
: "shopware-6-client";
const chokidar = require("chokidar");
const packagePath = path.join(__dirname, "..", "packages", target);
const pkg = require(path.join(packagePath, "package.json"));
if (pkg.scripts && pkg.scripts.dev) {
execa("yarn", ["dev"], {
stdio: "inherit",
cwd: packagePath,
});
} else {
chokidar
.watch([path.join(packagePath, "src")], {
ignoreInitial: true,
})
.on("all", async (event) => {
execa("yarn", ["build", target], {
stdio: "inherit",
});
});
execa("yarn", ["build", target], {
stdio: "inherit",
});
}