-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (68 loc) · 3.27 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
'use strict';
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')();
const gulpSequence = require('gulp-sequence');
const exec = require('child_process').exec;
var dev = process.argv.indexOf('--dist') < 0;
// -----------------------------------------------------------------------------
// Task: Polymer CLI - use the Polymer CLI for bundling and JS minification
// See polymer.json for Polymer CLI build options.
// -----------------------------------------------------------------------------
gulp.task('polymer:cli', function (cb) {
exec('node ./node_modules/polymer-cli/bin/polymer.js build', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
// -----------------------------------------------------------------------------
// getTask() loads external gulp task script functions by filename
// -----------------------------------------------------------------------------
function getTask(task) {
return require('./tasks/' + task)(gulp, plugins);
}
// -----------------------------------------------------------------------------
// Task: Compile : Scripts, Sass, EJS, All
// -----------------------------------------------------------------------------
gulp.task('compile:sass', getTask('compile.sass'));
gulp.task('compile:index', ['compile:sass'], getTask('compile.index'));
// -----------------------------------------------------------------------------
// Task: Serve : Start
// -----------------------------------------------------------------------------
gulp.task('serve:dev:start', getTask('serve.dev.start'));
gulp.task('serve:dist:start', ['dist'], getTask('serve.dist.start'));
// -----------------------------------------------------------------------------
// Task: Watch : Source, Public, All
// -----------------------------------------------------------------------------
gulp.task('watch:public', getTask('watch.public'));
// -----------------------------------------------------------------------------
// Task: Dist (Build app ready for deployment)
// clean, compile:sass, compile:index, bundle (using polymer cli), copy
// -----------------------------------------------------------------------------
gulp.task('dist', function(cb) {
gulpSequence(
'dist:clean',
'compile:index',
'polymer:cli',
'dist:copy'
)(cb);
});
// -----------------------------------------------------------------------------
// Task: Dist : Copy extra files for deployment, that weren't bundled.
// -----------------------------------------------------------------------------
gulp.task('dist:copy', getTask('dist.copy'));
// -----------------------------------------------------------------------------
// Task: Dist : Clean 'dist/'' folder
// -----------------------------------------------------------------------------
gulp.task('dist:clean', getTask('dist.clean'));
// -----------------------------------------------------------------------------
// Task: Default (compile source, start server, watch for changes)
// run "gulp --dist" to serve up files from the build directory.
// -----------------------------------------------------------------------------
gulp.task('default', function (cb) {
if (dev) {
gulpSequence('compile:index', 'watch:public', 'serve:dev:start')(cb);
} else {
gulpSequence('serve:dist:start')(cb);
}
});