Created
January 4, 2017 11:19
-
-
Save MikhailRoot/578bd2a6449ccdd5e7e18c99735cab3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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