-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
96 lines (80 loc) · 1.91 KB
/
gulpfile.babel.js
File metadata and controls
96 lines (80 loc) · 1.91 KB
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
import gulp from 'gulp';
import connect from 'gulp-connect';
import browserify from 'browserify';
import watchify from 'watchify';
import stringify from 'stringify';
import babelify from 'babelify';
import source from 'vinyl-source-stream';
import autoprefixer from 'gulp-autoprefixer';
import concat from 'gulp-concat';
import sass from 'gulp-sass';
const autoprefixerOptions = {
browsers: [
"Android 2.3",
"Android >= 4",
"Chrome >= 20",
"Firefox >= 24",
"Explorer >= 8",
"iOS >= 6",
"Opera >= 12",
"Safari >= 6"
]
};
gulp.task('connect', () => {
connect.server({
root: './',
livereload: true
});
});
gulp.task('html', function () {
gulp.src('./*')
.pipe(connect.reload());
});
gulp.task('js', function () {
gulp.src('./dist/js/bundle.js')
.pipe(connect.reload());
});
gulp.task('watch', function () {
gulp.watch(['./*.html'], ['html']);
gulp.watch(['./dist/js/bundle.js'], ['js'])
});
gulp.task('bundle', () => {
let b = browserify({
entries : ['./main.js'],
cache : {},
packagecache : {},
plugin: watchify
})
.transform(stringify, {
appliesTo : {
includeExtensions : ['.html'],
minify : true
}
})
.transform(babelify, {
presets : ['es2015']
})
b.on('update', bundle);
bundle();
function bundle() {
console.log("I'm rebundling...");
b.bundle()
.on('error', function(err){
console.log(err.message);
this.emit('end');
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('dist/js/'))
}
});
gulp.task('sass', () => {
return gulp.src('./**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer(autoprefixerOptions))
.pipe(concat('style.css'))
.pipe(gulp.dest('./dist/css/'))
});
gulp.task('css', function() {
gulp.watch('app/**/*.scss', ['sass']);
})
gulp.task('default', ['connect', 'watch', 'bundle', 'css', 'html']);