-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
71 lines (59 loc) · 1.75 KB
/
gulpfile.js
File metadata and controls
71 lines (59 loc) · 1.75 KB
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
'use strict';
// Include Gulp and other build automation tools and utilities
// See: https://github.com/gulpjs/gulp/blob/master/docs/API.md
var gulp = require('gulp');
require('gulp-grunt')(gulp); // add all the gruntfile tasks to gulp
var watch = require('gulp-watch');
var runSequence = require('run-sequence');
var clean = require('gulp-clean');
var $ = require('gulp-load-plugins')();
var webpack = require('webpack');
var argv = require('minimist')(process.argv.slice(2));
// Settings
var DEST = 'dist'; // The build output folder
var RELEASE = !!argv.release; // Minimize and optimize during a build?
// The default task
gulp.task('default', ['build', 'watch']);
// JSHint
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
gulp.task('lint', function() {
return gulp.src('src/*.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish));
//.pipe(jshint.reporter('fail'));
});
// Bundle
gulp.task('bundle', function (cb) {
var started = false;
var config = require('./config/webpack.js')(RELEASE);
var bundler = webpack(config);
function bundle(err, stats) {
if (err) {
throw new $.util.PluginError('webpack', err);
}
if (!started) {
started = true;
return cb();
}
}
bundler.run(bundle);
});
// Move lib to example
gulp.task("move-library", function() {
return gulp.src("lib/*.js").pipe(gulp.dest("example/js"));
});
// Clean task
gulp.task('build-clean', function() {
return gulp.src(DEST).pipe(clean());
});
// Build the app from source code
gulp.task('build', function(cb) {
runSequence('build-clean', 'lint', 'bundle', 'grunt-test', 'move-library', cb);
});
// Watcher
gulp.task('watch', function () {
watch(['src/**', 'test/**'], function() {
gulp.start('build');
});
});