Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const elixir = require('laravel-elixir');
elixir.extend('nghtml2js', function(sources,moduleName,prefix,destFolder,destfileName) {
const ngHtml2Js = require("gulp-ng-html2js");
const htmlmin = require('gulp-htmlmin');
const concat = require("gulp-concat");
const uglify = require("gulp-uglify");
new elixir.Task('nghtml2js',function(){
return gulp.src(sources)
.pipe(htmlmin({
collapseWhitespace: true,
includeAutoGeneratedTags: false
}))
.pipe(ngHtml2Js({
moduleName: moduleName,
prefix: prefix
}))
.pipe(concat(destfileName))
.pipe(uglify())
.pipe(gulp.dest(destFolder));
}).watch(sources);
});
// usage example
elixir(mix => {
// mix styles and scripts then call this snippet to compile html templates into angularjs module
mix.nghtml2js('resources/assets/js/components/*.html','ModuleName','/templates/','resources/assets/js/','ModuleName-tpls.js')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.