-
Notifications
You must be signed in to change notification settings - Fork 49
/
gulpfile.js
66 lines (55 loc) · 1.62 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
var gulp = require('gulp');
var path = require('path');
var del = require('del');
var Server = require('karma').Server;
var $ = require('gulp-load-plugins')({
pattern: '*',
});
var withTests = $.util.env.tests;
var webpackConfig = require('./webpack.config.js')['development'];
var webpackConfigProd = require('./webpack.config.js')['production'];
var src = 'src/';
var dist = 'dist/';
gulp.task('scripts-dev', function() {
return gulp.src(webpackConfig.entry.app)
.pipe($.webpackStream(webpackConfig))
.pipe(gulp.dest(dist))
.pipe($.size({
title: 'js'
}));
});
gulp.task('scripts-prod', function() {
return gulp.src(webpackConfigProd.entry.app)
.pipe($.webpackStream(webpackConfigProd))
.pipe($.uglify({preserveComments: 'license'}))
.pipe($.stripDebug())
.pipe(gulp.dest(dist))
.pipe($.size({
title: 'js'
}));
});
gulp.task('test', function(done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('watch', function() {
gulp.watch(src + '**/*.js', ['scripts-dev', 'scripts-prod']);
});
gulp.task('clean', function(cb) {
del([dist]).then(function() {
cb();
});
});
var defaultTasks = ['scripts-dev' , 'scripts-prod'];
// add test to the list of default tasks
if (withTests) {
defaultTasks.push('test');
}
// waits until clean is finished then builds the project
gulp.task('build', ['clean'], function() {
gulp.start(defaultTasks);
});
// by default build project and then watch files
gulp.task('default', ['build', 'watch']);