-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
68 lines (58 loc) · 1.81 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
var gulp = require('gulp');
var util = require('gulp-util');
var watch = require('gulp-watch');
var notify = require('gulp-notify');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var browserify = require('browserify');
var babelify = require('babelify');
var globify = require('require-globify');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var es = require('event-stream');
var runSequence = require('run-sequence');
var dev = false;
gulp.task('scss', function() {
return gulp.src('scss/style.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('chrome/css'))
.pipe(notify("Compiled SCSS"));
});
gulp.task('js', function() {
var files = [
'js/content.js'
];
var tasks = files.map(function(entry) {
return browserify({
entries: [entry],
transform: [globify]
})
.transform(babelify.configure({
presets: ["es2015"]
}))
.bundle()
.on('error', function (e) {
console.log(e);
})
.pipe(source(entry))
.pipe(buffer())
.pipe(dev ? sourcemaps.init({loadMaps: true}) : util.noop())
.pipe(uglify().on('error', function(e) {
console.log(e);
}))
.pipe(dev ? sourcemaps.write() : util.noop())
.pipe(gulp.dest('chrome'))
.pipe(notify("Compiled JS"));
});
return es.merge.apply(null, tasks);
});
gulp.task('default', function() {
runSequence('scss', 'js');
});
gulp.task('dev', function() {
dev = true;
runSequence('scss', 'js');
gulp.watch('scss/**/*.scss', ['scss']);
gulp.watch('js/**/*.js', ['js']);
});