-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
65 lines (60 loc) · 1.93 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
// Dependencies
const gulp = require('gulp'),
gutil = require('gulp-util'),
connect = require('gulp-connect'),
uglify = require('gulp-uglify');
rename = require('gulp-rename'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
babelify = require('babelify')
sass = require('gulp-sass')
,
autoprefixer = require('gulp-autoprefixer'),
nano = require('gulp-cssnano'),
sourcemaps = require('gulp-sourcemaps')
gulp.task('build:es6', function() {
return browserify({
entries: './src/js/index.js',
debug: true
})
.transform("babelify", {presets: ['es2015']})
.bundle()
.on('error', function (err) {
gutil.log("Error : " + err.message);
this.emit('end'); // This is needed for the watch task, or it'll hang on error
})
.pipe(source('crim-citations.js'))
.pipe(buffer())
// .pipe(uglify())
.on('error', function (err) { gutil.log("Error : " + err.message); })
.pipe(rename('crim-citations.js'))
.pipe(gulp.dest('dist/js/'));
});
gulp.task('build:css', function() {
return gulp.src('src/scss/**/*.scss')
.pipe(sass().on('error', function(err) {
gutil.log('Error: ' + err.message);
this.emit('end');
}))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(sourcemaps.init())
.pipe(nano())
.pipe(sourcemaps.write('.'))
.on('error', function(err) {
gutil.log("Error : " + err.message);
this.emit('end');
})
.pipe(gulp.dest('dist/css/'));
});
gulp.task('watch', function() {
gulp.watch('src/scss/**/*.scss', ['build:css']);
gulp.watch('src/js/**/*.js', ['build:es6']);
})
gulp.task('webserver', function() {
connect.server({livereload: true, port: 8888});
});
gulp.task('default', ['build:es6', 'build:css']);
gulp.task('run', ['webserver', 'build:es6', 'build:css', 'watch']);