-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
99 lines (83 loc) · 2.75 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
98
99
var gulp = require('gulp');
var usemin = require('gulp-usemin');
var uglify = require('gulp-uglify');
var minifyHtml = require('gulp-minify-html');
var minifyCss = require('gulp-minify-css');
var compass = require('gulp-compass');
var inject = require('gulp-inject');
var imagemin = require('gulp-imagemin');
var jshint = require('gulp-jshint');
var rev = require('gulp-rev');
var webserver = require('gulp-webserver');
// Constants
var SERVER_PORT = 31415;
var htmlPaths = ['./src/app/**/*.html','src/common/**/*.html'];
var sassPaths = ['./src/app/assets/styles/**/*.scss'];
var jsPaths = ['./src/app/**/*.js', 'src/common/**/*.js'];
var imagePaths = ['./src/app/assets/images/**/*.*'];
var fontPaths = ['./src/app/assets/fonts/**/*.*'];
var dataPath = './data/**/*.json';
var outputBaseDirectory = "./build/";
var dataBuildDirectory = outputBaseDirectory+'data/';
var vendorPath = 'src/vendor/**/*.js';
gulp.task('webserver', function() {
gulp.src('./build')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true,
port:SERVER_PORT
}));
});
gulp.task('compass', function () {
return gulp.src(sassPaths)
.pipe(compass({
css: 'build/min/styles',
sass: 'src/app/assets/styles',
image: 'src/app/assets/images'
}))
.on('error', function(err) {
console.log(err.message);
})
.pipe(gulp.dest(outputBaseDirectory+'min/css'))
});
gulp.task('lint', function() {
return gulp.src(jsPaths)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'))
.pipe(gulp.dest(outputBaseDirectory))
});
gulp.task('images', function() {
return gulp.src(imagePaths)
.pipe(imagemin(imagePaths))
.pipe(gulp.dest(outputBaseDirectory+'assets/images'));
});
gulp.task('compile', ['images', 'compass', 'lint'], function() {
gulp.src(htmlPaths)
.pipe(gulp.dest(outputBaseDirectory));
gulp.src(vendorPath)
.pipe(gulp.dest(outputBaseDirectory+'vendor/'));
gulp.src(dataPath)
.pipe(gulp.dest(dataBuildDirectory));
gulp.src(fontPaths)
.pipe(gulp.dest(outputBaseDirectory+'assets/fonts/'));
});
// Serve tasks
gulp.task('reload:html', function () {
console.log("Reloading html");
return gulp.src(htmlPaths)
.pipe(gulp.dest(outputBaseDirectory))
})
gulp.task('reload:json', function () {
console.log("Reloading json");
return gulp.src(dataPath)
.pipe(gulp.dest(dataBuildDirectory))
})
gulp.task('watch', function () {
gulp.watch(sassPaths, ['compass']);
gulp.watch(jsPaths, ['lint']);
gulp.watch(htmlPaths, ['reload:html']);
gulp.watch(dataPath, ['reload:json']);
});
gulp.task('default', ['webserver','watch']);