From 0f6aa3befb454a31846655c05314686059ef87a7 Mon Sep 17 00:00:00 2001 From: jendib Date: Wed, 31 Aug 2016 19:34:37 +0200 Subject: [PATCH] Concatenate Angular templates in minified JS file --- docs-web/src/main/webapp/Gruntfile.js | 46 +++++++++++++++++++++++++-- docs-web/src/main/webapp/package.json | 1 + 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/docs-web/src/main/webapp/Gruntfile.js b/docs-web/src/main/webapp/Gruntfile.js index 589b6bec..e2ebe98f 100644 --- a/docs-web/src/main/webapp/Gruntfile.js +++ b/docs-web/src/main/webapp/Gruntfile.js @@ -5,7 +5,7 @@ module.exports = function(grunt) { pkg: grunt.file.readJSON('package.json'), clean: { init: ['dist'], - after: ['dist/style.css', 'dist/docs.js', 'dist/share.js', 'dist/less.css', 'dist/app'] + after: ['dist/style.css', 'dist/docs.js', 'dist/share.js', 'dist/less.css', 'dist/app', 'dist/partial'] }, ngAnnotate: { options: { @@ -64,6 +64,44 @@ module.exports = function(grunt) { dest: 'dist/share.min.js' } }, + ngtemplates: { + docs: { + cwd: 'src', + src: 'partial/docs/*.html', + dest: 'dist/docs.min.js', + options: { + append: true, + htmlmin: { + collapseBooleanAttributes: true, + collapseWhitespace: true, + removeAttributeQuotes: true, + removeComments: true, + removeEmptyAttributes: true, + removeRedundantAttributes: true, + removeScriptTypeAttributes: true, + removeStyleLinkTypeAttributes: true + } + } + }, + share: { + cwd: 'src', + src: 'partial/share/*.html', + dest: 'dist/share.min.js', + options: { + append: true, + htmlmin: { + collapseBooleanAttributes: true, + collapseWhitespace: true, + removeAttributeQuotes: true, + removeComments: true, + removeEmptyAttributes: true, + removeRedundantAttributes: true, + removeScriptTypeAttributes: true, + removeStyleLinkTypeAttributes: true + } + } + } + }, copy: { dist: { expand: true, @@ -118,9 +156,11 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-ng-annotate'); grunt.loadNpmTasks('grunt-text-replace'); grunt.loadNpmTasks('grunt-apidoc'); + grunt.loadNpmTasks('grunt-angular-templates'); // Default tasks. - grunt.registerTask('default', ['clean:init', 'ngAnnotate', 'concat:docs', 'concat:share', 'less', 'concat:css', 'cssmin', - 'uglify:docs', 'uglify:share', 'copy', 'clean:after', 'cleanempty', 'htmlrefs:index', 'htmlrefs:share', 'replace', 'apidoc']); + grunt.registerTask('default', ['clean:init', 'ngAnnotate', 'concat:docs', 'concat:share', 'less', 'concat:css', + 'cssmin', 'uglify:docs', 'uglify:share', 'ngtemplates:docs', 'ngtemplates:share', 'copy', 'clean:after', + 'cleanempty', 'htmlrefs:index', 'htmlrefs:share', 'replace', 'apidoc']); }; \ No newline at end of file diff --git a/docs-web/src/main/webapp/package.json b/docs-web/src/main/webapp/package.json index d741dbd3..d3daccdf 100644 --- a/docs-web/src/main/webapp/package.json +++ b/docs-web/src/main/webapp/package.json @@ -37,6 +37,7 @@ }, "devDependencies": { "grunt": "^1.0.1", + "grunt-angular-templates": "^1.1.0", "grunt-apidoc": "^0.11.0", "grunt-cleanempty": "^1.0.4", "grunt-contrib-clean": "^1.0.0",