Browserify transform to minify and compile angular templates into angular modules. Based on browserify-ng-html2js
$ npm install browserify-ng-htmlmin2js --save-dev
Pass a configured ngHtmlMin2Js
instance as a browserify transform
.
var browserify = require('browserify');
var gulp = require('gulp');
var ngHtmlMin2Js = require('browserify-ng-htmlmin2js');
var source = require('vinyl-source-stream');
gulp.task('scripts', function () {
return browserify('./src/app.js')
.transform(ngHtmlMin2Js({
module: 'templates', // optional module name
extension: 'ngt', // optionally specify what file types to look for
baseDir: "src/js", // optionally specify base directory for filename
prefix: '', // optionally specify a prefix to be added to the filename
minify: { // optionally specify options to pass to html-minifier
collapseWhitespace: true,
removeComments: true
} // leave undefined to disable minification
}
}))
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'));
});