-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (46 loc) · 1.28 KB
/
gulpfile.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
51
52
53
54
55
56
57
var gulp = require('gulp'),
bs = require('browser-sync').create(),
bg = require("gulp-bg"),
ps = require('ps-node');
var POLYSERVE_PORT = 8080,
elementName = 'wid-d3-import';
var browserSyncConfig = function(path, cb) {
bs.init({
proxy: 'localhost:' + POLYSERVE_PORT,
startPath: path
});
bs.reload;
process.on('exit', function() {
bs.exit();
});
};
var watchComponent = function() {
gulp.watch(['./*.html', 'demo/**/*.html', 'test/**/*.html'], bs.reload);
};
gulp.task('polyserve', function(cb) {
ps.lookup({
command: 'polyserve',
psargs: '-f'
}, function(err, resultList) {
if (err) {
throw new Error(err);
}
if (!resultList.length) {
bg('./node_modules/polyserve/bin/polyserve', '-p ' + POLYSERVE_PORT)();
}
cb();
});
});
gulp.task('serve', ['polyserve'], function(cb) {
browserSyncConfig('/components/' + elementName + '/demo/', cb);
watchComponent();
});
gulp.task('serve:doc', ['polyserve'], function(cb) {
browserSyncConfig('/components/' + elementName + '/', cb);
watchComponent();
});
gulp.task('test:watch', ['polyserve'], function(cb) {
browserSyncConfig('/components/' + elementName + '/test/', cb);
watchComponent();
});
try { require('web-component-tester').gulp.init(gulp); } catch (err) {}