diff options
author | Tim Baumann <tim@timbaumann.info> | 2017-09-23 22:02:01 +0200 |
---|---|---|
committer | Alexander Biehl <alexbiehl@gmail.com> | 2017-09-23 22:02:01 +0200 |
commit | e99aefb50ca63e2dbcc95841efbb53cea90151d8 (patch) | |
tree | 3ab0cebcd012122631336281dceb389dd0fd4506 /haddock-api/resources/html/gulpfile.js | |
parent | fe4c6c7d2907a79118d836e72c0442d666091524 (diff) |
Add compile step that bundles and compresses JS files (#684)
* Add compile step that bundles and compresses JS files
Also, manage dependencies on third-party JS libraries using NPM.
* Compile JS from TypeScript
* Enable 'noImplicitAny' in TypeScript
* QuickJump: use JSX syntax
* Generate source maps from TypeScript for easier debugging
* TypeScript: more accurate type
* Separate quick jump css file from ocean theme
Diffstat (limited to 'haddock-api/resources/html/gulpfile.js')
-rw-r--r-- | haddock-api/resources/html/gulpfile.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/haddock-api/resources/html/gulpfile.js b/haddock-api/resources/html/gulpfile.js new file mode 100644 index 00000000..c7cb6782 --- /dev/null +++ b/haddock-api/resources/html/gulpfile.js @@ -0,0 +1,27 @@ +const gulp = require('gulp'); +const uglify = require('gulp-uglify'); +const browserify = require('browserify'); +const source = require('vinyl-source-stream'); +const buffer = require('vinyl-buffer'); +const tsify = require('tsify'); +const sourcemaps = require('gulp-sourcemaps'); + +function buildJS(targetFileName, files) { + var b = browserify({ entries: files, debug: true }); + return b + .plugin(tsify) + .bundle() + .pipe(source(targetFileName)) + .pipe(buffer()) + .pipe(sourcemaps.init({loadMaps: true})) + .pipe(uglify().on('error', function(e) { console.log(e); })) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest('.')); +} + +gulp.task('build-js', function() { + buildJS('quick-jump.min.js', ['./js-src/quick-jump.tsx']); + buildJS('haddock-bundle.min.js', ['./js-src/init.ts']); +}); + +gulp.task('default', ['build-js']);
\ No newline at end of file |