Skip to content

Instantly share code, notes, and snippets.

@fongreecss
Last active April 29, 2020 12:08
Show Gist options
  • Save fongreecss/4f7b08b9e0e5cea03919a43372c53d4e to your computer and use it in GitHub Desktop.
Save fongreecss/4f7b08b9e0e5cea03919a43372c53d4e to your computer and use it in GitHub Desktop.
Typescript, watchify, gulp - minimal conf with error logging on the console
var gulp = require('gulp');
var ts = require('gulp-typescript');
var browserify = require("browserify");
var source = require('vinyl-source-stream');
var watchify = require("watchify");
var tsify = require("tsify");
var gutil = require("gulp-util");
gulp.task('typescript', function () {
return gulp.src('./app/src/**/*.ts')
.pipe(ts())
.pipe(gulp.dest('./app/dist'));
});
var watchedBrowserify = watchify(browserify({
basedir: '.',
debug: true,
entries: ['app/src/main.ts'],
cache: {},
packageCache: {}
}).plugin(tsify));
function bundle() {
return watchedBrowserify
.bundle()
.on("error", gutil.log)
.pipe(source('main.js'))
.pipe(gulp.dest("app/dist"));
}
gulp.task("default", bundle);
watchedBrowserify.on("update", bundle);
watchedBrowserify.on("log", gutil.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment