forked from mikejacobson/jquery-bootstrap-scrolling-tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
102 lines (87 loc) · 2.5 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
100
101
102
var gulp = require('gulp');
var browserSync = require('browser-sync');
var cleancss = require('gulp-clean-css');
var fs = require('fs');
var header = require('gulp-header');
var include = require('gulp-include');
var jshint = require('gulp-jshint');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var util = require('gulp-util');
var headerFilePath = 'src/js/header.js';
gulp.task('browser-sync', function () {
browserSync.init({
startPath: 'run',
server: {
baseDir: './'
},
port: 3000,
ghostMode: false
});
});
gulp.task('bundlejs', function () {
return gulp.src('src/js/_main.js')
.pipe(include())
.on('error', console.log)
.pipe(header(fs.readFileSync(headerFilePath, 'utf8')))
.pipe(rename('jquery.scrolling-tabs.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('lintdist', function () {
return gulp.src('dist/jquery.scrolling-tabs.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('lintsrc', function () {
return gulp.src('src/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('minjs', function () {
return gulp.src('dist/jquery.scrolling-tabs.js')
.pipe(rename('jquery.scrolling-tabs.min.js'))
.pipe(uglify())
.pipe(header(fs.readFileSync(headerFilePath, 'utf8')))
.pipe(gulp.dest('dist'));
});
gulp.task('mincss', function () {
return gulp.src('dist/jquery.scrolling-tabs.css')
.pipe(rename('jquery.scrolling-tabs.min.css'))
.pipe(cleancss())
.pipe(header(fs.readFileSync(headerFilePath, 'utf8')))
.pipe(gulp.dest('dist'));
});
gulp.task('sass', function () {
return gulp.src('src/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(header(fs.readFileSync(headerFilePath, 'utf8')))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function () {
gulp.watch('src/scss/*.scss', ['buildcss']);
gulp.watch('src/js/*.js', ['buildjs', 'buildcss']);
});
gulp.task('buildcss', function (cb) {
runSequence('sass',
'mincss',
cb);
});
gulp.task('buildjs', function (cb) {
runSequence('lintsrc',
'bundlejs',
'lintdist',
'minjs',
cb);
});
gulp.task('build', function (cb) {
runSequence('buildcss',
'buildjs',
cb);
});
gulp.task('default', function () {
runSequence('build',
'browser-sync',
'watch');
});