This repository has been archived by the owner on Feb 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
77 lines (67 loc) · 2.41 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var cssnano = require('gulp-cssnano');
var flatten = require('gulp-flatten');
var del = require('del');
// -------------------------------------------------------------
// Variables
// -------------------------------------------------------------
var dest = 'web/compiled';
var cssDir = 'web/css/**/*.css';
var jsDir = 'web/js/**/*.js';
var vendorDir = 'web/vendor';
// -------------------------------------------------------------
// Default task
// -------------------------------------------------------------
gulp.task('default', ['watch', 'build']);
// -------------------------------------------------------------
// Build task
// -------------------------------------------------------------
gulp.task('build', ['clean'], function() {
// build asset files
gulp.src(cssDir)
// compiled
.pipe(concat(`site.compiled.css`))
.pipe(gulp.dest(dest))
// compiled min
.pipe(concat(`site.compiled.min.css`))
.pipe(cssnano())
.pipe(gulp.dest(dest));
gulp.src(jsDir)
// compiled
.pipe(concat(`app.compiled.js`))
.pipe(ngAnnotate())
.pipe(gulp.dest(dest))
// compiled.min
.pipe(concat(`app.compiled.min.js`))
.pipe(uglify())
.pipe(gulp.dest(dest));
// build vendor files
gulp.src([`${vendorDir}/**/*.css`, `!${vendorDir}/**/*.min.css`])
.pipe(concat(`vendor.compiled.css`))
.pipe(gulp.dest(dest));
gulp.src([`${vendorDir}/**/*.min.css`])
.pipe(concat(`vendor.compiled.min.css`))
.pipe(gulp.dest(dest));
gulp.src([`${vendorDir}/**/angular.js`, `${vendorDir}/**/*.js`, `!${vendorDir}/**/*.min.js`])
.pipe(concat(`vendor.compiled.js`))
.pipe(gulp.dest(dest));
gulp.src([`${vendorDir}/**/angular.min.js`, `${vendorDir}/**/*.min.js`])
.pipe(concat(`vendor.compiled.min.js`))
.pipe(gulp.dest(dest));
// copy map files
gulp.src(`${vendorDir}/**/*.map`)
.pipe(flatten())
.pipe(gulp.dest(dest));
});
gulp.task('clean', function() {
del([`${dest}/*`]);
});
// -------------------------------------------------------------
// Watch task
// -------------------------------------------------------------
gulp.task('watch', function () {
gulp.watch([cssDir, jsDir], ['build'])
});