-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpFile.js
77 lines (60 loc) · 1.53 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
const _PROJECTNAME = 'require';
var gulp = require('gulp'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
browserSync = require('browser-sync').create();
var tinypngToken = 'hHrU0V0DGG3tNna6R1sqNNOqqU-x1S4u';
// Content structure
var source = {
content: '*',
location: './'
};
source.js = {
content: '*.js',
location: 'js/'
};
source.index = {
content: '*.html',
location: './'
};
var dist = {
content: '*',
location: 'dist/'
};
dist.js = source.js;
dist.js.location = dist.location + dist.js.location;
// JS
gulp.task('js', function() {
gulp.src(source.js.location + source.js.content)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(gulp.dest(dist.js.location + _PROJECTNAME + '.js'));
gulp.src([dist.js.location + _PROJECTNAME + '.js'])
.pipe(rename({
extname: '.min.js'
}))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(gulp.dest(dist.js.location));
});
gulp.task('watch', function () {
gulp.watch(source.css.location + source.css.content, ['css']);
});
gulp.task('watch', ['css'], function () {
browserSync.reload();
});
// Watch scss AND html files, doing different things with each.
gulp.task('serve', ['oai'], function () {
// Serve files from the root of this project
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch(source.css.location + source.css.content, ['oai-watch']);
gulp.watch(source.index.content).on("change", browserSync.reload);
});
gulp.task('default', ['serve']);