Last active
September 11, 2019 14:45
-
-
Save sanderhahn/8595191 to your computer and use it in GitHub Desktop.
Minify and templateCache your Angular Templates using Gulp
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
var gulp = require('gulp'); | |
var uglify = require('gulp-uglify'); | |
var concat = require('gulp-concat'); | |
var templates = require('gulp-angular-templatecache'); | |
var minifyHTML = require('gulp-minify-html'); | |
// Minify and templateCache your Angular Templates | |
// Add a 'templates' module dependency to your app: | |
// var app = angular.module('appname', [ ... , 'templates']); | |
gulp.task('templates', function () { | |
gulp.src([ | |
'./**/*.html', | |
'!./node_modules/**' | |
]) | |
.pipe(minifyHTML({ | |
quotes: true | |
})) | |
.pipe(templates('templates.js')) | |
.pipe(gulp.dest('tmp')); | |
}); | |
// Concat and uglify all your JavaScript | |
gulp.task('default', ['templates'], function() { | |
gulp.src([ | |
'./**/*.js', | |
'!./node_modules/**', | |
'!./gulpfile.js', | |
'!./dist/all.js' | |
]) | |
.pipe(concat('all.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('dist')); | |
}); |
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
{ | |
"devDependencies": { | |
"gulp-angular-templatecache": "~0.3.0", | |
"gulp-uglify": "~0.1.0", | |
"gulp-concat": "~2.1.7", | |
"gulp-ngmin": "~0.1.2", | |
"gulp-minify-html": "~0.1.0", | |
"gulp": "~3.4.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment