-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (65 loc) · 2.48 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
66
67
68
69
70
71
72
73
74
75
76
77
/* jshint esversion: 6 */
const gulp = require('gulp');
const sourcemap = require('gulp-sourcemaps');
const compiler = require('google-closure-compiler-js').gulp();
const prettify = require('gulp-js-prettify')
const util = require('gulp-util')
// const frontMatter = require('gulp-front-matter');
// const swig = require('gulp-swig');
const debug = false;
const dense = !debug; // Should the code be compiled?
const pretty = debug; // Should the code be reformatted with sensible whitespace?
// Expose the original source to the browser.
// In theory this would make it easier to debug, but somehow Chrome is failing
// to set breakpoints in the mapped source, and things get wonky in the ES5
// runtime.
const do_sourcemap = false;
const gulp_frontmatter_options = {
remove: true,
property: 'data.page' // for compliance with Jekyll
};
const gulp_options = {
base: './src/'
};
// const consume_files = [
// './src/module/logger.js', // Provide logger first (core dependency)
// './src/module/*.js', // All modules and internal dependencies
// './src/*.js' // The main {pirate.js}
// ];
// console.log('Path: ' + process.cwd())
gulp.task('pirate.min.js', function() {
var noop = util.noop();
return gulp.src(['./_includes/pirate.js'], gulp_options)
// .pipe(frontMatter(gulp_frontmatter_options))
// .pipe(swig())
.pipe(sourcemap.init())
.pipe(compiler({
compilationLevel: (dense ? 'ADVANCED' : 'SIMPLE'),
warningLevel: 'VERBOSE',
languageIn: 'ECMASCRIPT6',
languageOut: 'ECMASCRIPT5',
defines: {
// ENABLE_LOGGING: (!dense)
},
processCommonJsModules: true,
outputWrapper: '(function(){\n%output%\n}).call(this)',
jsOutputFile: './dist/pirate.min.js', // outputs single file
createSourceMap: (do_sourcemap ? './dist/pirate.min.js.map' : null)
}))
.pipe((dense && !pretty) ? noop : prettify({ collapseWhitespace: true }))
.pipe(do_sourcemap ? sourcemap.write('./') : noop)
.pipe(gulp.dest('./_includes/'));
});
gulp.task('testkit.min.js', function(){
return gulp.src(['./js/test/testkit.js'], {base: './js/'})
.pipe(compiler({
compilationLevel: 'SIMPLE',
warningLevel: 'VERBOSE',
languageIn: 'ECMASCRIPT5',
languageOut: 'ECMASCRIPT5',
outputWrapper: "%output%",
jsOutputFile: "./dist/testkit.min.js"
}))
.pipe(gulp.dest('./js/test/'));
});
gulp.task('default', ['pirate.min.js']);