Last active
April 29, 2020 12:08
-
-
Save fongreecss/4f7b08b9e0e5cea03919a43372c53d4e to your computer and use it in GitHub Desktop.
Typescript, watchify, gulp - minimal conf with error logging on the console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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