-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
97 lines (82 loc) · 2.53 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
94
95
96
97
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var es = require('event-stream');
var _ = require('lodash');
// static dependencies for Angular2
var angularDeps = [
'node_modules/systemjs/node_modules/es6-module-loader/node_modules/traceur/bin/traceur.js',
'node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.js',
'node_modules/systemjs/dist/system.js',
'node_modules/zone.js/zone.js',
'node_modules/zone.js/long-stack-trace-zone.js',
'./traceurOptions.js'
];
var vendorScripts = [
{ 'jquery': [ 'node_modules/jquery/dist/jquery.js' ] },
{ 'lodash': [ 'node_modules/lodash/index.js' ] }
];
// Angular2 AtScript to ES5
gulp.task('build:ng2', $.shell.task(['sh ng2build.sh']));
// strip off the sourceMaps.
gulp.task('build:strip_maps', $.shell.task(["sh strip_maps.sh"]));
// Concat all static dependencies for Angular2
gulp.task('build:shim', function() {
return gulp.src(angularDeps)
.pipe($.concat('es6-shim.js'))
.pipe(gulp.dest('./app/libs'));
});
gulp.task('scripts:vendor', function () {
var streams = _.map(vendorScripts, function(vendor) {
var name = _.keys(vendor);
var scripts = vendor[name];
var target = 'app/libs'
return gulp.src(scripts)
.pipe($.concat(name + '.js'))
.pipe(gulp.dest(target));
});
return es.merge.apply(null, streams);
});
// Compile Any Other Sass Files You Added (app/styles)
gulp.task('styles:scss', function () {
return gulp.src(['app/styles/*.scss'])
.pipe($.rubySass({
style: 'expanded',
precision: 10,
loadPath: ['app/styles', 'node_modules/bootstrap-sass/assets/stylesheets'],
sourcemap: false
}))
.pipe($.autoprefixer('last 1 version'))
.pipe(gulp.dest('app/styles'))
.pipe($.size({title: 'styles:scss'}));
});
// Clean Output Directory
gulp.task('clean', function (cb) {
return gulp.src(['app/libs/*', 'app/styles/*.css'])
.pipe($.clean());
});
gulp.task('serve', function () {
browserSync.init({
server: {
baseDir: ['app']
},
notify: false
});
gulp.watch(['app/styles/**/*.scss'], ['styles:scss']);
});
// Synchronous build
// 1. clean
// 2. ng2build
// 3. concat es6 shim file
gulp.task('default', function(cb) {
runSequence('clean',
'build:ng2',
'build:shim',
'build:strip_maps',
'scripts:vendor',
'styles:scss',
cb);
});