-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
88 lines (76 loc) · 2.15 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');
var deploy = require('gulp-gh-pages');
var del = require('del');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglifyjs');
var webserver = require('gulp-webserver');
var config = {
assetsDir: './assets',
bowerDir: './bower_components',
HTMLDir: './html',
publicDir: './public',
};
gulp.task('clean:public', function(cb) {
del([
config.publicDir + '/*',
'!' + config.publicDir + '/CNAME',
], cb);
});
gulp.task('assets', function() {
return gulp.src(config.assetsDir + '/**')
.pipe(gulp.dest(config.publicDir));
});
gulp.task('icons', function() {
return gulp.src(config.bowerDir + '/fontawesome/fonts/**.*')
.pipe(gulp.dest(config.publicDir + '/fonts'));
});
gulp.task('html', function() {
return gulp.src(config.HTMLDir + '/**')
.pipe(gulp.dest(config.publicDir));
});
gulp.task('js', function() {
return gulp.src([
config.bowerDir + '/jquery/dist/jquery.min.js',
config.bowerDir + '/bootstrap-sass-official/assets/javascripts/bootstrap.js',
])
.pipe(uglify('app.js', {
compress: false,
outSourceMap: true,
}))
.pipe(gulp.dest(config.publicDir + '/js'));
});
gulp.task('css', function() {
return gulp.src('css/app.scss')
.pipe(sourcemaps.init())
.pipe(sass({
style: 'compressed',
includePaths: [
config.bowerDir + '/bootstrap-sass-official/assets/stylesheets',
config.bowerDir + '/fontawesome/scss',
]
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.publicDir + '/css'));
});
gulp.task('deploy', function () {
return gulp.src(config.publicDir + '/**/*')
.pipe(deploy());
});
gulp.task('build', function (cb) {
runSequence('clean:public', ['assets', 'icons', 'css', 'js', 'html'], cb);
});
gulp.task('watch', function () {
gulp.watch(['html/**/*', 'assets/**/*', 'bower_components/**/*', 'css/**/*'], ['build']);
});
gulp.task('serve', function() {
gulp.src('public')
.pipe(webserver({
host: '0.0.0.0',
port: 6772,
livereload: {enable: true, port: 2345},
open: true,
}));
});
gulp.task('default', ['watch', 'serve']);