forked from NetworkedCoders/speech-rank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (76 loc) · 2.95 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
less = require('gulp-less'),
minifyCss = require('gulp-minify-css'),
stripCssComments = require('gulp-strip-css-comments');
var bases = {
application: 'app/',
production: 'build/web/'
};
var paths = {
scripts: ['scripts/**/*.js', '!scripts/libs/**/*.js'],
less: ['less/*.less'],
libs: [
'scripts/libs/angular.min.js', // AngularJS
'scripts/libs/angular-animate.min.js', // ngAnimate
'scripts/libs/jquery-2.2.0.min.js', // jQuery
'scripts/libs/angular-ui-router.min.js', // ngRoute
'scripts/libs/loading-bar.min.js', // Loading animation
'scripts/libs/angular-toastr.min.js', // angular messages
'scripts/libs/bootstrap.min.js' // boostrap
],
html: ['index.html'],
fonts: ['fonts/**/'],
images: ['images/**/'],
extras: ['.htaccess'],
templates: ['templates/**/*.html'],
json: ['json-data/**/']
};
// minify, concatenate libs
// minify and concatenate scripts in default script directory
gulp.task('scripts', function() {
gulp.src(paths.libs, {cwd: bases.application})
.pipe(uglify())
.pipe(concat('libs.min.js'))
.pipe(gulp.dest(bases.production + 'scripts/'));
gulp.src(paths.scripts, {cwd: bases.application})
.pipe(jshint())
.pipe(jshint.reporter('default'))
//.pipe(uglify())
.pipe(concat('app.min.js'))
.pipe(gulp.dest(bases.production + 'scripts/'));
});
// convert less to css remove comments, minify and concatenate css styles, copy css file to production
gulp.task('styles', function() {
return gulp.src(paths.less, {cwd: bases.application})
.pipe(less())
.pipe(stripCssComments({all:true}))
.pipe(concat('styles.css'))
.pipe(minifyCss())
.pipe(gulp.dest(bases.production + 'css/'));
});
// copy all other files to production directly
gulp.task('copy', function() {
// Copy html
gulp.src(paths.html, {cwd: bases.application})
.pipe(gulp.dest(bases.production));
// Copy extra html files
gulp.src(paths.extras, {cwd: bases.application})
.pipe(gulp.dest(bases.production));
gulp.src(paths.images, {cwd: bases.application})
.pipe(gulp.dest(bases.production + 'images/'));
// Copy templates
gulp.src(paths.templates, {cwd: bases.application})
.pipe(gulp.dest(bases.production + 'templates/'));
// Copy fonts
gulp.src(paths.fonts, {cwd: bases.application})
.pipe(gulp.dest(bases.production + 'fonts/'));
});
gulp.task('watchForChanges', function() {
gulp.watch(bases.application + paths.less, ['styles']);
gulp.watch(bases.application + 'scripts/**/*.js', ['scripts']);
gulp.watch(bases.application + '**/*.html', ['copy']);
});
gulp.task('default', ['scripts', 'styles', 'copy', 'watchForChanges']);