forked from vmware-archive/clarity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
95 lines (85 loc) · 2.39 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright (c) 2016 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
var gulp = require("gulp");
var env = require('gulp-env');
var requireDir = require('require-dir');
var runSequence = require('run-sequence');
var util = require('gulp-util');
/**
* Check for prod flag during gulp task executions
*/
if(util.env.prod){
env.set({NODE_ENV: "prod"});
} else {
env.set({NODE_ENV: "dev"});
}
requireDir('./build/tasks', {recurse: true});
/**
* Cleans, compiles and bundles the entire application, before cleaning up the tmp/ folder again.
*/
gulp.task('build', function (callback) {
var prod = process.env.NODE_ENV==="prod";
return runSequence(
'clean',
prod ?
['sass','typescript', 'html', 'bundle', 'svg'] :
['sass','typescript', 'html'],
callback
);
});
/**
* Builds one time, then watches for changes and starts Browsersync
*/
gulp.task("serve", function (callback) {
var prod = process.env.NODE_ENV==="prod";
return runSequence(
'build',
prod ?
['sass:watch', 'typescript:watch', 'html:watch', 'bundle:watch'] :
['sass:watch', 'typescript:watch', 'html:watch'],
'live',
callback
);
});
/**
* Builds the application in production mode and runs all tests once on it.
*/
gulp.task("test", function (callback) {
env.set({NODE_ENV: "prod"}); // We only run tests in production mode for now
env.set({TESTING: true});
return runSequence(
'build',
'karma:verbose',
'aot:test',
callback
);
});
/**
* Builds the application in production mode, runs all tests on it,
* then watches for file changes to re-run tests.
*/
gulp.task("test:watch", function(callback) {
env.set({NODE_ENV: "prod"}); // We only run tests in production mode for now
env.set({TESTING: true});
return runSequence(
'build',
['sass:watch', 'typescript:watch', 'html:watch', 'bundle:watch'],
'karma:watch',
callback
);
});
/**
* Publishes the Clarity package to the NPM registry
*/
gulp.task("npm:prepare", function(callback) {
env.set({NODE_ENV: "prod"}); // The build is in production mode
return runSequence(
'build',
'aot',
'npm:all',
callback
);
});