Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Browserify relative template paths #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions browserify-typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}, {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can inherit options? That way ng2TemplateParser can use target or we can change base options

base: '/app',
useRelativePaths: true,
supportNonExistentFiles: false
})((err, result) => {
this.push(result);
process.nextTick(next);
});
});
});

if (options.watch) {
b = watchify(b, options.watchifyOptions);
Expand All @@ -62,4 +76,4 @@ module.exports = function(options) {
function noop(){
return new stream.PassThrough({ objectMode: true });
}
}
};
2 changes: 2 additions & 0 deletions browserify-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down