-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
77 lines (65 loc) · 2.37 KB
/
gulpfile.js
File metadata and controls
77 lines (65 loc) · 2.37 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
72
73
74
75
76
77
/**
* Created by leefsmp on 4/16/15.
*/
var del = require("del");
var gulp = require("gulp");
var bower = require('gulp-bower');
var uglify = require('gulp-uglify');
var webpack = require("gulp-webpack");
var vinylPaths = require('vinyl-paths');
var ngAnnotate = require('gulp-ng-annotate');
var config = {
buildDir: './www/build',
bowerDir: './www/lib/bower_components'
};
///////////////////////////////////////////////////////////////////////////
// Clean Task
//
///////////////////////////////////////////////////////////////////////////
gulp.task('clean', function () {
return gulp.src(config.buildDir + '/*.js', {read: false})
.pipe(vinylPaths(del));
});
///////////////////////////////////////////////////////////////////////////
// bower task
//
///////////////////////////////////////////////////////////////////////////
gulp.task('bower', function() {
return bower({directory: config.bowerDir}).pipe(
gulp.dest(config.bowerDir));
});
///////////////////////////////////////////////////////////////////////////
// Webpack build task
//
///////////////////////////////////////////////////////////////////////////
gulp.task("webpack:build", ['clean','bower'], function(callback) {
var webpackConfig = require("./config/webpack.config.js");
return gulp.src('www/js/app.js')
.pipe(webpack(webpackConfig))
.pipe(gulp.dest(config.buildDir));
});
///////////////////////////////////////////////////////////////////////////
// Compress task: uglyfy and minify js
//
///////////////////////////////////////////////////////////////////////////
gulp.task('compress', ['webpack:build'], function() {
return gulp.src(config.buildDir + '/*.js')
.pipe(ngAnnotate())
.pipe(uglify({mangle: false}))
.pipe(gulp.dest(config.buildDir));
});
///////////////////////////////////////////////////////////////////////////
// Debug build
//
///////////////////////////////////////////////////////////////////////////
gulp.task('build-debug', ['webpack:build']);
///////////////////////////////////////////////////////////////////////////
// Production build
//
///////////////////////////////////////////////////////////////////////////
gulp.task('build-prod', ['compress']);
///////////////////////////////////////////////////////////////////////////
// Default task
//
///////////////////////////////////////////////////////////////////////////
gulp.task('default', ['build-prod']);