This repository was archived by the owner on May 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
114 lines (99 loc) · 2.74 KB
/
gulpfile.js
File metadata and controls
114 lines (99 loc) · 2.74 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
var argv = require('yargs').argv;
var gulp = require('gulp');
// Plugins.
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var rename = require('gulp-rename');
var gulpif = require('gulp-if');
var jsonlint = require("gulp-jsonlint");
var header = require('gulp-header');
var pkg = require('./version.json');
var banner = ['/**',
' * @name <%= pkg.name %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.link %>',
' */',
''].join('\n');
// We only want to process our own non-processed JavaScript files.
var jsPath = ['./js/search.js', './js/*/*.js', '!./js/assets/*'];
var jsAssets = ['./js/assets/*.min.js', '!./js/assets/angular.js', '!./js/assets/angular.min.js'];
var sassPath = './scss/*.scss';
var jsonPath = [ './version.json' ]
var buildDir = './build';
/**
* Run Javascript through JSHint.
*/
gulp.task('jshint', function() {
return gulp.src(jsPath)
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
/**
* Process SCSS using libsass
*/
gulp.task('sass', function () {
gulp.src(sassPath)
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'compressed',
includePaths: [
'bower_components/compass-mixins/lib',
'bower_components/foundation/scss'
]
}).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./stylesheets'));
});
/**
* Watch files for changes and run tasks.
*/
gulp.task('watch', function() {
gulp.watch(jsPath, ['jshint']);
gulp.watch(sassPath, ['sass']);
gulp.watch(jsonPath, ['json']);
});
/**
* Watch javascript files for changes.
*/
gulp.task('js-watch', function() {
gulp.watch(jsPath, ['jshint']);
});
/**
* Build single app.js file.
*/
gulp.task('appJs', function () {
gulp.src(jsPath)
.pipe(sourcemaps.init())
.pipe(concat('search.js'))
.pipe(ngAnnotate())
.pipe(gulpif(argv.production, uglify()))
.pipe(sourcemaps.write('/maps'))
.pipe(gulpif(argv.production, rename({extname: ".min.js"})))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest(buildDir))
});
/**
* Build single app.js file.
*/
gulp.task('assetsJs', function () {
gulp.src(jsAssets)
.pipe(concat('assets.js'))
.pipe(gulpif(argv.production, rename({extname: ".min.js"})))
.pipe(gulp.dest(buildDir))
});
/**
* Check json files.
*/
gulp.task('json', function() {
gulp.src(jsonPath)
.pipe(jsonlint())
.pipe(jsonlint.reporter());
});
// Tasks to compile sass and watch js file.
gulp.task('default', ['sass', 'watch']);
gulp.task('build', ['appJs', 'assetsJs', 'sass']);