forked from mgechev/angular-seed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_change_tools.ts
More file actions
44 lines (40 loc) · 950 Bytes
/
Copy pathcode_change_tools.ts
File metadata and controls
44 lines (40 loc) · 950 Bytes
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
import {PORT, ENABLE_HOT_LOADING, HOT_LOADER_PORT, APP_SRC, PROJECT_ROOT, APP_DEST} from '../config';
import {join} from 'path';
import * as ng2HotLoader from 'angular2-hot-loader';
import * as browserSync from 'browser-sync';
let runServer = () => {
let routes:any = {
[`/${APP_DEST}`]: APP_DEST,
'/node_modules': 'node_modules'
};
browserSync({
port: PORT,
startPath: '/',
server: {
baseDir: APP_DEST,
routes: routes
}
});
};
let listen = () => {
if (ENABLE_HOT_LOADING) {
ng2HotLoader.listen({
port: HOT_LOADER_PORT,
processPath: file => {
return file.replace(join(PROJECT_ROOT, APP_SRC), join('dist', 'dev'));
}
});
}
runServer();
};
let changed = files => {
if (!(files instanceof Array)) {
files = [files];
}
if (ENABLE_HOT_LOADING) {
ng2HotLoader.onChange(files);
} else {
browserSync.reload(files);
}
};
export { listen, changed };