From 1fbb27c033c0f64a1eab5fe48bc66fb8d995b70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20von=20der=20Gr=C3=BCn?= Date: Wed, 30 Dec 2015 14:42:27 +0100 Subject: [PATCH 1/2] fix(grunt:cdnify): preserve cdnified scripts in build Previously, the script references in index.html that were changed by the cdnify step would later be overwritten by the usemin task. Now, cdnify runs before useminPrepare and the usemin task is configured to include references for cdnified scripts right before the actual block replacements. --- templates/common/root/_Gruntfile.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/templates/common/root/_Gruntfile.js b/templates/common/root/_Gruntfile.js index 7786cd09d..5ea52745a 100644 --- a/templates/common/root/_Gruntfile.js +++ b/templates/common/root/_Gruntfile.js @@ -363,7 +363,7 @@ module.exports = function (grunt) { // concat, minify and revision files. Creates configurations in memory so // additional tasks can operate on them useminPrepare: { - html: '<%%= yeoman.app %>/index.html', + html: '<%%= yeoman.dist %>/index.html', options: { dest: '<%%= yeoman.dist %>', flow: { @@ -391,6 +391,17 @@ module.exports = function (grunt) { ], patterns: { js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']] + }, + blockReplacements: { + // Include cdnified scripts followed by usemin dest script + js: function (block) { + var scripts = block.src.filter(function (src) { + return src.startsWith('//'); + }).concat(block.dest); + return scripts.map(function (src) { + return ''; + }).join('\n'); + } } } }, @@ -495,6 +506,14 @@ module.exports = function (grunt) { // Copies remaining files to places other tasks can use copy: { + html: { + files: [{ + expand: true, + cwd: '<%= yeoman.app %>', + src: '*.html', + dest: '<%= yeoman.dist %>', + }], + }, dist: { files: [{ expand: true, @@ -503,7 +522,6 @@ module.exports = function (grunt) { dest: '<%%= yeoman.dist %>', src: [ '*.{ico,png,txt}', - '*.html', 'images/{,*/}*.{webp}', 'styles/fonts/{,*/}*.*' ] @@ -606,6 +624,8 @@ module.exports = function (grunt) { 'clean:dist', 'wiredep',<% if (typescript) { %> 'tsd:refresh',<% } %> + 'copy:html', + 'cdnify', 'useminPrepare', 'concurrent:dist', 'postcss', @@ -613,7 +633,6 @@ module.exports = function (grunt) { 'concat', 'ngAnnotate', 'copy:dist', - 'cdnify', 'cssmin', 'uglify', 'filerev', From b46dd595a4035aa6e3934548975ef013861c6215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20von=20der=20Gr=C3=BCn?= Date: Wed, 30 Dec 2015 15:04:03 +0100 Subject: [PATCH 2/2] fix(grunt:cdnify): prevent grunt-google-cdn from using pre-release versions Previously, grunt-google-cdn resolved the angular version requirement of "^1.4.0" to some 1.5 pre-release. Unfortunately there is no release of grunt-google-cdn that includes the relevant fix. So we now require a specific commit instead of a released version. --- templates/common/root/_package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/common/root/_package.json b/templates/common/root/_package.json index 24e2dcf7e..3ddbc3a4b 100644 --- a/templates/common/root/_package.json +++ b/templates/common/root/_package.json @@ -45,7 +45,7 @@ "grunt-contrib-uglify": "^0.7.0", "grunt-contrib-watch": "^0.6.1", "grunt-filerev": "^2.1.2", - "grunt-google-cdn": "^0.4.3",<% if (!coffee) { %> + "grunt-google-cdn": "github:btford/grunt-google-cdn#bca6658",<% if (!coffee) { %> "grunt-jscs": "^1.8.0",<% } %> "grunt-newer": "^1.1.0", "grunt-ng-annotate": "^0.9.2",