-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
79 lines (69 loc) · 2.08 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
var path = require('path');
var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var sass = require('gulp-sass');
var merge = require('merge-stream');
var autoprefixer = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var runSequence = require('run-sequence');
var git = require('gulp-git');
var clean = require('gulp-clean');
var webserver = require('gulp-webserver');
var config = {
bootstrapDir: './bower_components/bootstrap-sass',
jqueryDir: './bower_components/jquery',
distDir: './',
srcDir: './scss',
host: 'localhost',
port: '8080'
};
gulp.task('styles', function() {
gulp.src(config.srcDir + '/style.scss')
.pipe(sass({
includePaths: [config.bootstrapDir + '/assets/stylesheets'],
}))
.pipe(autoprefixer({
browsers: ['last 2 version', 'iOS >= 8.1', 'Android >= 4.4'],
cascade: false
}))
.pipe(minifyCSS({keepSpecialComments: 1}))
.pipe(gulp.dest(config.distDir));
});
gulp.task('javascripts', function() {
gulp.src(config.jqueryDir + '/dist/jquery.min.js')
.pipe(gulp.dest(config.distDir + '/javascripts'));
gulp.src(config.bootstrapDir + '/assets/javascripts/bootstrap.min.js')
.pipe(gulp.dest(config.distDir + '/javascripts'));
});
gulp.task('fonts', function() {
return gulp.src(config.bootstrapDir + '/assets/fonts/**/*')
.pipe(gulp.dest(config.distDir + '/fonts'));
});
gulp.task('watch', function() {
gulp.watch(config.srcDir + '**/*.html', ['html']);
gulp.watch(config.srcDir + '**/*.scss', ['styles']);
gulp.watch(config.srcDir + '**/*.js', ['javascripts']);
});
gulp.task('clean', function(callback) {
return gulp.src('dist/*', {read: false})
.pipe(clean());
});
gulp.task('build', function(callback) {
runSequence('clean', ['styles', 'javascripts', 'fonts'], callback);
});
gulp.task('webserver', function() {
gulp.src(config.distDir)
.pipe(webserver({
host: config.host,
port: config.port,
livereload: true
}));
});
gulp.task('start', function(callback) {
runSequence(
'build',
'webserver',
'watch',
callback
)
});