-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (52 loc) · 1.44 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
58
59
60
61
62
const { series, parallel, src, dest, watch } = require("gulp");
var fs = require('fs');
var Candyman = require("candyman");
var uglify = require("gulp-uglify");
var babel = require("gulp-babel");
var concat = require("gulp-concat");
var del = require("del");
// Setup path for gulp
var paths = {
scripts: {
src: "app/**/*.js",
dest: "build/"
}
};
// Config to connect with iot device
var config = JSON.parse(fs.readFileSync('./config.json'));
// Candayman config setup
var candymanConfig = config.candymanConfig;
candymanConfig.targetDevices[0].startFile = paths.scripts.dest + config.buildMainFile;
function clean() {
return del(["build"]);
}
function scripts() {
return src(paths.scripts.src, { sourcemaps: true })
.pipe(babel())
/* .pipe(uglify()) */
.pipe(concat(buildMainFile))
.pipe(dest(paths.scripts.dest));
}
function watchs() {
watch(paths.scripts.src, scripts);
}
function deploy() {
var candyman = new Candyman(candymanConfig);
return candyman.deploy();
}
/*
* Specify if tasks run in series or parallel using `gulp.series` and `gulp.parallel`
*/
var build = series(clean, parallel(scripts));
/*
* You can use CommonJS `exports` module notation to declare tasks
*/
exports.clean = clean;
exports.scripts = scripts;
exports.watch = watchs;
exports.build = build;
exports.deploy = series(build, deploy);
/*
* Define default task that can be called by just running `gulp` from cli
*/
exports.default = build;