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

Conversation

michaelknoch
Copy link

Implement relative url to inline html transformation in browserify gulp task.
This adds the possibility to use relative template urls.

.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

@Yimiprod
Copy link

Yimiprod commented Aug 5, 2016

After having tested it there's one problem, watching the html to run the build doesn't work correctly, the build is done but the transform isn't applied, so we don't see any changes, the only thing that work is to reload the build.

@michaelknoch
Copy link
Author

yes, you are right @Yimiprod.
It would be possible to trigger browserify build with ng2TemplateParser transformation again when html has changed, but i'm not sure if this will feel comfortable, because the process takes some seconds for me.

@Yimiprod
Copy link

Yimiprod commented Aug 5, 2016

Tried something that "almost" work:

  var b = browserify(options.src, options.browserifyOptions)
    .plugin(tsify, options.tsifyOptions);

  if (options.watch) {
    watchify(b, options.watchifyOptions);
    b.on('update', bundle);
    b.on('log', options.onLog);
  }

  b.transform(function(file) {
      return through(function (buf, enc, next) {
        ng2TemplateParser({contents: buf, path: file}, options.browserifyOptions)((err, result) => {
          this.push(result);
          process.nextTick(next);
        });
      });
    });

That way, if we change the template, it not trigger rebuild BUT if we change the controller who call that template, the build is correctly done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants