-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
61 lines (51 loc) · 2.14 KB
/
gulpfile.babel.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
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const htmlmin = require('gulp-htmlmin');
const eslint = require('gulp-eslint');
const inlinesrc = require('gulp-inline-source');
const csslint = require('gulp-csslint');
const babel = require('gulp-babel');
const stripDebug = require('gulp-strip-debug');
// Note: the '**/' is needed as a prefix to
// preserve the directory structure.
// To move and minify JS assests.
var DEST = 'dist/';
gulp.task('eslint', function() {
return gulp.src(['src/**/*.js', '!**/boot*', '!**/jquery*', '!**/knock*', '!**/xlsx*', '!node_modules/', '!node_modules/**', '!dist/', '!dist/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('js', ['eslint'], function() {
return gulp.src(['src/**/*.js', '!node_modules/', '!node_modules/**', '!dist/', '!dist/**'])
.pipe(stripDebug())
.pipe(babel())
.pipe(uglify().on('error', function(e){
console.log(e);
}))
.pipe(gulp.dest(DEST));
});
gulp.task('img', function() {
return gulp.src(['src/**/*.png', '**/images/*.jpg', '**/images/*.gif', '!node_modules/', '!node_modules/**', '!dist/', '!dist/**'])
.pipe(gulp.dest(DEST));
});
// // just to run csslint, since CSS gets inlined in HTML, and copy over bootstrap
// gulp.task('csslint', function() {
// return gulp.src(['src/**/*.css', '!node_modules/', '!node_modules/**', '!dist/', '!dist/**'])
// .pipe(csslint())
// .pipe(csslint.formatter());
// });
// just to run csslint, since CSS gets inlined in HTML, and copy over bootstrap
gulp.task('css', function() {
return gulp.src(['src/**/boot*.css', 'src/**/all*.css', 'src/**/fa-*', '!node_modules/', '!node_modules/**', '!dist/', '!dist/**'])
.pipe(gulp.dest(DEST));
});
gulp.task('html', ['css'], function() {
return gulp.src(['src/index.html', '!node_modules/', '!node_modules/**', '!dist/', '!dist/**'])
.pipe(inlinesrc())
.pipe(htmlmin({collapseWhitespace: true,minifyJS:true,minifyCSS:true,removeComments:false}).on('error', function(e){
console.log(e);
}))
.pipe(gulp.dest(DEST));
});
gulp.task('main', ['html', 'js', 'img']);