-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
51 lines (45 loc) · 1.35 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
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var watchify = require("watchify");
var sourcemaps = require('gulp-sourcemaps');
var buffer = require('vinyl-buffer');
var gutil = require("gulp-util");
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
gulp.task('sass', function() {
return gulp.src('assets/scss/**/*.scss') // Gets all files ending with .scss in app/scss and children dirs
.pipe(sass())
.pipe(gulp.dest('assets/css'))
})
var watchedBrowserify = watchify(browserify({
basedir: '.',
debug: true,
entries: ['assets/js/_src/main.js'],
cache: {},
packageCache: {}
}))
.transform('babelify', {
presets: ['es2015'],
plugins: ['transform-async-to-generator', 'transform-runtime'],
extensions: ['.js']
})
function bundle() {
return watchedBrowserify
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest("assets/js/dist"));
}
gulp.task('default', function () {
return watchedBrowserify
.bundle()
});
gulp.task('watch', function() {
gulp.watch('assets/scss/**/*.scss', ['sass']);
})
watchedBrowserify.on("update", bundle);
watchedBrowserify.on("log", gutil.log);