-
Notifications
You must be signed in to change notification settings - Fork 29
/
gulpfile.js
executable file
·85 lines (76 loc) · 2.52 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
var gulp = require('gulp'),
less = require('gulp-less'),
path = require('path'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
sourcemaps = require('gulp-sourcemaps');
function swallowError (error) {
console.log(error.toString());
this.emit('end');
}
gulp.task('browser-sync', function () {
var files = [
'themes/botwiki/css/*.css',
'themes/botwiki/js/*.js'
];
browserSync.init(files, {
proxy: "localhost:5000"
});
});
gulp.task('styles', function() {
return gulp.src('themes/botwiki/src/styles/main.*')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.on('error', swallowError)
.pipe(autoprefixer('last 3 version', 'android >= 3', { cascade: true }))
.on('error', swallowError)
.pipe(gulp.dest('themes/botwiki/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.on('error', swallowError)
.pipe(gulp.dest('themes/botwiki/css'))
.pipe(notify({ message: 'Styles task complete' }))
.pipe(reload({stream:true}));
});
gulp.task('scripts', function() {
return gulp.src('themes/botwiki/src/scripts/*.js')
.on('error', swallowError)
.pipe(jshint('tests/.jshintrc'))
.on('error', swallowError)
.pipe(jshint.reporter('default'))
.on('error', swallowError)
.pipe(gulp.dest('themes/botwiki/js'))
.on('error', swallowError)
.pipe(rename({suffix: '.min'}))
/*
TODO: Find a good way to only load source map in development. See https://knpuniversity.com/screencast/gulp/sourcemaps-only-dev
Commenting out for now.
*/
// .pipe(sourcemaps.init())
.pipe(uglify())
.on('error', swallowError)
// .pipe(sourcemaps.write())
.pipe(gulp.dest('themes/botwiki/js'))
.on('error', swallowError)
.pipe(notify({ message: 'Scripts task complete' }));
});
gulp.task('clean', function() {
return gulp.src(['themes/botwiki/css', 'themes/botwiki/js'], {read: false})
.pipe(clean());
});
gulp.task('watch', function() {
gulp.watch('themes/botwiki/src/styles/*.less', ['styles']);
gulp.watch('themes/botwiki/src/scripts/*.js', ['scripts']);
});
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts', 'browser-sync', 'watch');
});