-
Notifications
You must be signed in to change notification settings - Fork 51
/
gulpfile.babel.js
executable file
·68 lines (60 loc) · 1.64 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
62
63
64
65
66
67
68
'use strict';
import gulp from 'gulp';
import del from 'del';
import runSequence from 'run-sequence';
import gulpLoadPlugins from 'gulp-load-plugins';
import closure from 'gulp-closure-compiler';
import injectVersion from 'gulp-inject-version';
const $ = gulpLoadPlugins();
const SRC_DIR = 'src';
const DIST_DIR = 'dist';
function license() {
return $.license('Apache', {
organization: 'Eric Bidelman. All rights reserved. - @version %%GULP_INJECT_VERSION%%',
tiny: true
});
}
gulp.task('lint', () => {
return gulp.src([
`${SRC_DIR}/*.js`
])
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
// Run scripts through Closure compiler.
gulp.task('build', () => {
return gulp.src([
`${SRC_DIR}/appmetrics.js`
])
.pipe(closure({
compilerPath: 'node_modules/google-closure-compiler/compiler.jar',
fileName: 'appmetrics.js',
compilerFlags: {
compilation_level: 'SIMPLE_OPTIMIZATIONS',
// warning_level: 'VERBOSE',
language_in: 'ECMASCRIPT6_STRICT',
language_out: 'ECMASCRIPT5'
}
}))
.pipe(license()) // Add license to top.
.pipe(injectVersion())
.pipe($.rename({suffix: '.min'}))
.pipe(gulp.dest(DIST_DIR));
});
// gulp.task('test', function() {
// return gulp.src(['test/*.js'], {read: false})
// .pipe($.mocha())
// .on('error', function(error) {
// console.error(error);
// process.exit(1);
// });
// });
// Clean generated files.
gulp.task('clean', () => {
del([DIST_DIR], {dot: true});
});
// Build production files.
gulp.task('default', ['clean'], cb =>
runSequence('lint', 'build', cb)
);