From 67cb1431ee9b3c2a8f3f54d978651c2e175c79f1 Mon Sep 17 00:00:00 2001 From: Michael Knoch Date: Sat, 18 Jun 2016 01:24:16 +0200 Subject: [PATCH 1/2] add inline-ng2 dependencies --- browserify-typescript/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/browserify-typescript/package.json b/browserify-typescript/package.json index 83186a7..2cf8c3a 100644 --- a/browserify-typescript/package.json +++ b/browserify-typescript/package.json @@ -10,10 +10,12 @@ "dependencies": { "browserify": "^13.0.0", "gulp": "^3.9.1", + "gulp-inline-ng2-template": "^2.0.4", "gulp-sourcemaps": "^1.6.0", "gulp-uglify": "^1.5.3", "lodash.merge": "^4.3.2", "prettysize": "0.0.3", + "through2": "^2.0.1", "tsify": "^0.14.1", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", From d6bb9951bb8431b0e8595e6a1ae4ce79d8aacaac Mon Sep 17 00:00:00 2001 From: Michael Knoch Date: Sat, 18 Jun 2016 01:26:20 +0200 Subject: [PATCH 2/2] transform relative urls to inline html --- browserify-typescript/index.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/browserify-typescript/index.js b/browserify-typescript/index.js index 56134e0..2cc4ebe 100644 --- a/browserify-typescript/index.js +++ b/browserify-typescript/index.js @@ -8,7 +8,9 @@ var gulp = require('gulp'), buffer = require('vinyl-buffer'), sourcemaps = require('gulp-sourcemaps'), uglify = require('gulp-uglify'), - stream = require('stream'); + stream = require('stream'), + through = require('through2'), + ng2TemplateParser = require('gulp-inline-ng2-template/parser'); var defaultOptions = { watch: false, @@ -31,13 +33,25 @@ var defaultOptions = { onLog: function(log){ console.log((log = log.split(' '), log[0] = pretty(log[0]), log.join(' '))); } -} +}; module.exports = function(options) { options = merge(defaultOptions, options); var b = browserify(options.src, options.browserifyOptions) - .plugin(tsify, options.tsifyOptions); + .plugin(tsify, options.tsifyOptions) + .transform(function (file) { + return through(function (buf, enc, next) { + ng2TemplateParser({contents: buf, path: file}, { + base: '/app', + useRelativePaths: true, + supportNonExistentFiles: false + })((err, result) => { + this.push(result); + process.nextTick(next); + }); + }); + }); if (options.watch) { b = watchify(b, options.watchifyOptions); @@ -62,4 +76,4 @@ module.exports = function(options) { function noop(){ return new stream.PassThrough({ objectMode: true }); } -} +};