-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (55 loc) · 1.7 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
/*
Sass + Browserify
*/
var gulp = require('gulp')
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var sass = require('gulp-sass')
var autoprefixer = require('gulp-autoprefixer')
var livereload = require('gulp-livereload')
var sourcemaps = require('gulp-sourcemaps')
var watchify = require('watchify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
gulp.task('styles', function() {
return gulp.src('src/modules/style.sass' )
.pipe(sourcemaps.init())
.pipe(sass({
style: 'expanded',
indentedSyntax: true,
errLogToConsole: true
}).on('error', sass.logError))
.pipe(autoprefixer('last 3 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest( 'src/min/' ))
});
gulp.task('default', ['styles'], function() {
livereload.listen();
gulp.watch('src/modules/**/*.sass', ['styles']);
gulp.watch([
'src/min/**/*',
'src/**/*.html',
], livereload.changed);
// Browserify
var b = browserify('./src/modules/main.js');
var w = watchify(b);
function bundle() {
return w.bundle()
.on('error', function(e){
gutil.log(e)
})
.pipe(source('bundle.js')) // convert to a file stream
.pipe(buffer()) // convert to a buffer
.pipe(sourcemaps.init({loadMaps: true}))
// transforms here
// .pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./src/min/'))
.pipe(livereload())
}
w.on('update', bundle);
w.on('log', gutil.log);
bundle();
});