-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
58 lines (48 loc) · 1.54 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
/* gulpfile.js */
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
babel = require('gulp-babel'),
// order is important for gulp-concat
// app.js *must* come last
sourceJS = [
'src/js/get-events.js',
'src/js/greet.js',
'src/js/local_storage.js',
'src/js/render-table.js',
'src/js/render-chart.js',
'src/js/repo-select.js',
'src/js/backgrounds.js',
'src/js/app.js'
];
// convert sass to css
// 'gulp-sass' listens for error events, but you have to enable logging
gulp.task('styles', function () {
gulp.src('src/css/**/*.scss')
.pipe(concat('dev-dash.scss'))
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'] // autoprefixer needs config object
}))
.pipe(gulp.dest('dist/css'));
});
// concatenate scripts
gulp.task('scripts', function () {
gulp.src(sourceJS)
.pipe(sourcemaps.init())
.pipe(concat('dev-dash.js'))
.pipe(babel({
presets: ['es2015'] // babel needs a config object
}))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/js'));
});
// init watcher
gulp.task('default', ['styles'], function() {
// watch source sass files and convert ono changes
gulp.watch('src/css/**/*.scss', ['styles']);
});