gulpfile.js
function inlineTemplate() {
  return gulp.src(['./src/app/**/*.ts'].concat(globalExcludes), {base: './'})
    .pipe(replace(/templateUrl.*\'/g, function (matched) {
      var fileName = matched.match(/\/.*html/g).toString();
      var dirName = this.file.relative.substring(0, this.file.relative.lastIndexOf('/'));
      var fileContent = fs.readFileSync(dirName + fileName, "utf8");
      return 'template: \`' + minifyTemplate(fileContent) + '\`';
    }))
    .pipe(gulp.dest(libraryBuild));
}
function inlineTemplate() {
  return gulp.src(['./src/app/**/*.ts'].concat(globalExcludes), {base: './'})
    .pipe(replace(/templateUrl.*\'/g, function (matched) {
      var fileName = matched.match(/\/.*html/g).toString();
      var dirName = this.file.relative.substring(0, this.file.relative.lastIndexOf('/'));
      var fileContent = fs.readFileSync(dirName + fileName, "utf8");
      return 'template: \`' + minifyTemplate(fileContent) + '\`';
    }))
    .pipe(gulp.dest(libraryBuild));
}
function inlineTemplate ( ) { return gulp . src ( [ './src/app/**/*.ts' ] . concat ( globalExcludes ) , { base : './' } ) . pipe ( replace ( / templateUrl.*\' / g , function ( matched ) { var fileName = matched . match ( / \/.*html / g ) . toString ( ) ; var dirName = this . file . relative . substring ( 0 , this . file . relative . lastIndexOf ( '/' ) ) ; var fileContent = fs . readFileSync ( dirName + fileName , "utf8" ) ; return 'template: \`' + minifyTemplate ( fileContent ) + '\`' ; } ) ) . pipe ( gulp . dest ( libraryBuild ) ) ; }
Typescript
 Inline HTML templates in component classes
Typescript Inline HTML templates in component classes