This repository was archived by the owner on Aug 7, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbefore-watch.js
37 lines (33 loc) · 1.48 KB
/
before-watch.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
const { getWebpackProcesses, runWebpackCompiler, stopWebpackCompiler } = require("./compiler");
module.exports = function ($logger, $liveSyncService, $devicesService, hookArgs) {
if (hookArgs.config) {
const appFilesUpdaterOptions = hookArgs.config.appFilesUpdaterOptions;
if (appFilesUpdaterOptions.bundle) {
$liveSyncService.on("liveSyncStopped", data => {
const webpackProcesses = getWebpackProcesses();
Object.keys(webpackProcesses).forEach(platform => {
const devices = $devicesService.getDevicesForPlatform(platform);
if (!devices || !devices.length) {
stopWebpackCompiler(platform);
}
});
});
process.on("exit", () => {
stopWebpackCompiler();
});
const platforms = hookArgs.config.platforms;
return Promise.all(platforms.map(platform => {
const env = hookArgs.config.env || {};
env.hmr = appFilesUpdaterOptions.useHotModuleReload;
const config = {
env,
platform,
bundle: appFilesUpdaterOptions.bundle,
release: appFilesUpdaterOptions.release,
watch: true
};
return runWebpackCompiler(config, hookArgs.projectData, $logger, $liveSyncService, hookArgs);
}));
}
}
}