-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (71 loc) · 1.82 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
/* global require */
var gulp = require("gulp");
var $ = require('gulp-load-plugins')();
var paths = {
scripts: "app/js/",
scripts_build: 'js/',
styles:'app/css/',
styles_build: 'css/'
};
var source = {
scripts: [
paths.scripts + 'app.module.js',
paths.scripts + 'modules/**/*.module.js',
paths.scripts + 'modules/**/*.js',
],
styles:paths.styles + '**/*.css'
};
var dest = {
js: 'app.js',
styles:'styles.css'
};
var vendor = {
source: require('./vendor.json'),
js: 'base.js',
css: 'base.css'
};
// JS APP
gulp.task('scripts', function () {
console.log('Building scripts..');
return gulp.src(source.scripts)
.pipe($.concat(dest.js))
.on('error', handleError)
.pipe(gulp.dest(paths.scripts_build))
.on('error', handleError);
});
gulp.task('styles', function () {
console.log('Building styles...');
return gulp.src(source.styles)
.pipe($.concat(dest.styles))
.on('error', handleError)
.pipe(gulp.dest(paths.styles_build))
.on('error', handleError);
});
gulp.task('vendor', function () {
console.log('Copying base vendor assets..');
var jsFilter = $.filter('**/*.js', {
restore: true
});
var cssFilter = $.filter('**/*.css', {
restore: true
});
return gulp.src(vendor.source)
.pipe($.expectFile(vendor.source))
.pipe(jsFilter)
.pipe($.concat(vendor.js))
.pipe(gulp.dest(paths.scripts_build))
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.concat(vendor.css))
.pipe(gulp.dest(paths.styles_build))
.pipe(cssFilter.restore());
});
gulp.task('default', [
'scripts',
'styles',
'vendor'
]);
function handleError(err) {
console.log(err.toString());
this.emit('end');
}