-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·46 lines (40 loc) · 1.26 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserify = require('browserify');
var babelify = require('babelify');
var uglify = require('gulp-uglify');
var through2 = require('through2');
var path = require('path');
gulp.task('sass', function () {
gulp.src('./app/app.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dist'));
});
gulp.task('assets', function () {
gulp.src('./app/assets/*')
.pipe(gulp.dest('./dist'));
});
gulp.task('data', function () {
gulp.src('./data/*')
.pipe(gulp.dest('./dist/data'));
});
gulp.task('babel', function () {
return gulp.src('./app/app.js')
.pipe(through2.obj(function (file, enc, next) {
browserify(file.path)
.transform(babelify.configure({ only: [ path.join(__dirname, 'src') ] }))
.bundle(function (err, res) {
if (err) { return next(err); }
file.contents = res;
next(null, file);
});
}))
.on('error', function (error) {
console.log(error.stack);
this.emit('end');
})
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
gulp.task('default', ['assets', 'data', 'sass', 'babel']);