-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
69 lines (58 loc) · 1.68 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
var gulp = require('gulp'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
uglify = require('gulp-uglify'),
browserify = require('browserify'),
watchify = require('watchify'),
babel = require('babelify'),
sass = require('gulp-sass'),
cssnano = require('gulp-cssnano'),
cssbyebye = require('css-byebye')
;
var postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
flexbugfixes = require('postcss-flexbugs-fixes')
;
function compile(watch) {
var bundler = watchify(
browserify('./lib/js/index.js', { debug: true })
.transform(babel, {presets: ["es2015"]})
.transform('browserify-shim', {global: true})
);
function rebundle() {
bundler.bundle()
.on('error', function(err) { console.error(err); this.emit('end'); })
.pipe(source('build.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./public/js'));
}
if (watch) {
bundler.on('update', function() {
console.log('-> bundling...');
rebundle();
console.log('->Done');
});
}
rebundle();
}
function watch() {
return compile(true);
};
gulp.task('build', function() { return compile(); });
gulp.task('watch', ['sass:watch'], function() { return watch(); });
gulp.task('default', ['watch', 'sass']);
gulp.task('sass', function () {
var cbbOptions = {
rulesToRemove: [ '.slick-loading .slick-list' ]
}
return gulp
.src('./lib/scss/app.scss')
.pipe( sass().on('error', sass.logError) )
.pipe( postcss([ autoprefixer(), flexbugfixes, cssbyebye( cbbOptions ) ] ) )
.pipe( cssnano( {safe:true} ) )
.pipe( gulp.dest( './public/css' ) );
});
gulp.task('sass:watch', function () {
gulp.watch('./lib/scss/*.scss', ['sass']);
});