From 33cd656614d333f708f3a3b0d41dad2339918784 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Fri, 4 Mar 2016 09:46:11 -0600 Subject: [PATCH 01/10] don't use version as an arg with grunt --- grunt/notification_slack.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grunt/notification_slack.js b/grunt/notification_slack.js index 231ea03..7fdf212 100644 --- a/grunt/notification_slack.js +++ b/grunt/notification_slack.js @@ -6,7 +6,7 @@ module.exports = function ( grunt ) { var envConfig = grunt.config( "env" ); var slackApiToken = grunt.config( "slackApiToken" ); - var deployVersion = grunt.config( "version" ); + var commit = grunt.config( "commit" ); var pkg = grunt.file.readJSON( "package.json" ); var pkgVersion = pkg.version || ""; var pkgName = pkg.name || "App"; @@ -28,7 +28,7 @@ module.exports = function ( grunt ) var slacker = new Slack( slackApiToken ); slacker.api( "chat.postMessage", { - text: pkgName + " build " + pkgVersion + " @" + deployVersion + " for " + host + text: pkgName + " build " + pkgVersion + " @" + commit + " for " + host + " should be available in about 10 minutes.", channel: slackChannel, username: "Release Bot" diff --git a/package.json b/package.json index 5886cc9..8af3e11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dominatr-grunt", - "version": "6.1.2", + "version": "6.1.3", "description": "Build all the things!", "scripts": { "test": "" From a91005b5bf29b6883e36dbbee2b8a74e92a757b2 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Fri, 4 Mar 2016 10:58:19 -0600 Subject: [PATCH 02/10] update dep grunt-aws to vokal fork --- grunt/notification_slack.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grunt/notification_slack.js b/grunt/notification_slack.js index 7fdf212..231ea03 100644 --- a/grunt/notification_slack.js +++ b/grunt/notification_slack.js @@ -6,7 +6,7 @@ module.exports = function ( grunt ) { var envConfig = grunt.config( "env" ); var slackApiToken = grunt.config( "slackApiToken" ); - var commit = grunt.config( "commit" ); + var deployVersion = grunt.config( "version" ); var pkg = grunt.file.readJSON( "package.json" ); var pkgVersion = pkg.version || ""; var pkgName = pkg.name || "App"; @@ -28,7 +28,7 @@ module.exports = function ( grunt ) var slacker = new Slack( slackApiToken ); slacker.api( "chat.postMessage", { - text: pkgName + " build " + pkgVersion + " @" + commit + " for " + host + text: pkgName + " build " + pkgVersion + " @" + deployVersion + " for " + host + " should be available in about 10 minutes.", channel: slackChannel, username: "Release Bot" diff --git a/package.json b/package.json index 8af3e11..04334b1 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "config-extend": "^0.1.0", "grunt": "^0.4.5", "grunt-angular-templates": "^0.5.7", - "grunt-aws": "^0.6.1", + "grunt-aws": "github:vokal/grunt-aws", "grunt-babel": "^6.0.0", "grunt-browserify": "^4.0.1", "grunt-contrib-clean": "^0.7.0", From 16f083193502782dc66f4f365f1829ea21c149f5 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 30 Mar 2016 10:50:30 -0500 Subject: [PATCH 03/10] SVG inlining --- grunt/aliases.yaml | 3 ++- grunt/ngtemplates.js | 6 +++--- grunt/svg_inline.js | 51 ++++++++++++++++++++++++++++++++++++++++++++ grunt/watch.js | 2 +- package.json | 8 ++++--- 5 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 grunt/svg_inline.js diff --git a/grunt/aliases.yaml b/grunt/aliases.yaml index caaaf4d..3b13b8e 100644 --- a/grunt/aliases.yaml +++ b/grunt/aliases.yaml @@ -5,9 +5,10 @@ build: - clean:build - truecolors_less - less + - svg_sprite + - svg_inline - ngtemplates - copy - - svg_sprite - browserify:build - postcss diff --git a/grunt/ngtemplates.js b/grunt/ngtemplates.js index e84fb26..7348a91 100644 --- a/grunt/ngtemplates.js +++ b/grunt/ngtemplates.js @@ -1,7 +1,7 @@ +"use strict"; + module.exports = function ( grunt ) { - "use strict"; - return { options: { module: "App", @@ -28,7 +28,7 @@ module.exports = function ( grunt ) true; }, dest: "build/templates.js", - cwd: "source" + cwd: ".inlined" } }; diff --git a/grunt/svg_inline.js b/grunt/svg_inline.js new file mode 100644 index 0000000..434a877 --- /dev/null +++ b/grunt/svg_inline.js @@ -0,0 +1,51 @@ +"use strict"; + +var inline = require( "web-resource-inliner" ); +var a = require( "async" ); + +module.exports = function ( grunt ) +{ + grunt.registerTask( "svg_inline", "Inline SVG use", function () + { + var done = this.async(); + var src = [ + "modules/*/templates/*.html", + "!modules/_app/templates/index.html" + ]; + + var tasks = + grunt.file.expandMapping( src, ".inlined", { cwd: "source" } ) + .map( function ( file ) + { + return function ( done ) + { + var fileContent = grunt.file.read( file.src ); + + inline.html( { + fileContent: fileContent, + images: false, + scripts: false, + links: false, + relativeTo: "build/" + }, function ( err, res ) + { + if( err ) + { + return done( err ); + } + grunt.file.write( file.dest, res ); + done(); + } ); + }; + } ); + + a.series( tasks, function ( err ) + { + if( err ) + { + grunt.fail.warn( err, err.stack ); + } + done(); + } ); + } ); +}; diff --git a/grunt/watch.js b/grunt/watch.js index fe32dee..799300a 100644 --- a/grunt/watch.js +++ b/grunt/watch.js @@ -33,7 +33,7 @@ module.exports = { sprite: { options: { cwd: "<%= svg_sprite.use.cwd %>" }, files: "<%= svg_sprite.use.src %>", - tasks: [ "svg_sprite" ] + tasks: [ "svg_sprite", "svg_inline", "ngtemplates" ] }, livereload: { options: { livereload: true }, diff --git a/package.json b/package.json index 04334b1..25b496f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dominatr-grunt", - "version": "6.1.3", + "version": "7.0.0", "description": "Build all the things!", "scripts": { "test": "" @@ -22,7 +22,7 @@ "config-extend": "^0.1.0", "grunt": "^0.4.5", "grunt-angular-templates": "^0.5.7", - "grunt-aws": "github:vokal/grunt-aws", + "grunt-aws": "^0.6.1", "grunt-babel": "^6.0.0", "grunt-browserify": "^4.0.1", "grunt-contrib-clean": "^0.7.0", @@ -50,12 +50,14 @@ "protractor": "^2.5.1" }, "dependencies": { + "async": "^2.0.0-rc.2", "autoprefixer": "^6.1.1", "aws-sdk": "^2.2.25", "babel-preset-es2015": "^6.3.13", "connect-modrewrite": "^0.8.2", "cssnano": "^3.3.2", "serve-static": "^1.10.0", - "slack-node": "^0.1.7" + "slack-node": "^0.1.7", + "web-resource-inliner": "^2.0.0" } } From 5ddfa0bc6f89b23354436a126a5cf080893b7903 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 30 Mar 2016 11:55:03 -0500 Subject: [PATCH 04/10] inline svgs in the index --- grunt/copy.js | 2 +- grunt/svg_inline.js | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/grunt/copy.js b/grunt/copy.js index 9660fc8..be7707a 100644 --- a/grunt/copy.js +++ b/grunt/copy.js @@ -16,7 +16,7 @@ module.exports = { ] }, index: { - src: "source/modules/_app/templates/index.html", + src: ".inlined/modules/_app/templates/index.html", dest: "build/index.html" } }; diff --git a/grunt/svg_inline.js b/grunt/svg_inline.js index 434a877..76c4ea7 100644 --- a/grunt/svg_inline.js +++ b/grunt/svg_inline.js @@ -8,10 +8,7 @@ module.exports = function ( grunt ) grunt.registerTask( "svg_inline", "Inline SVG use", function () { var done = this.async(); - var src = [ - "modules/*/templates/*.html", - "!modules/_app/templates/index.html" - ]; + var src = [ "modules/*/templates/*.html" ]; var tasks = grunt.file.expandMapping( src, ".inlined", { cwd: "source" } ) From 9ea96a64b9399a21bf52478683c89320925b65cf Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 6 Apr 2016 12:47:22 -0500 Subject: [PATCH 05/10] document SVG inline --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index fd328fa..ab21725 100644 --- a/README.md +++ b/README.md @@ -314,6 +314,9 @@ This list aims to be a reference and may not cover every detail of our implement - #### svg_sprite Generates svg sprites and their `.css` files based on images located in the `source/images/svg-sprite` directory. The output folder is `build/svg-sprite`. +- #### svg_inline + Injects SVG content referenced by SVG `` directly into the HTML document. + - #### svgmin Minification for `.svg` files during deployment. From c4cfadefececb9cbb33bed8c23c4f144012728a5 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 6 Apr 2016 13:12:40 -0500 Subject: [PATCH 06/10] update `other bits` --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab21725..b031504 100644 --- a/README.md +++ b/README.md @@ -371,7 +371,7 @@ module.exports = { }; ``` -Replacements are done at the subtask level, so the file above would not destroy the `copy:build` task in the process. For more information on writing task files, view the `load-grunt-config` [documenation](https://github.com/firstandthird/load-grunt-config#grunt-tasks-files). +Replacements are done at the subtask level, so the file above would not destroy the `copy:build` task in the process. For more information on writing task files, view the `load-grunt-config` [documentation](https://github.com/firstandthird/load-grunt-config#grunt-tasks-files). ## Other Bits @@ -381,6 +381,7 @@ While not required, we suggest adding the following lines to your `.gitignore` f /build /coverage /.instrumented +/.inlined ``` -The `/coverage` and `/.instrumented` directories are used during testing and erased with each run. Files in these folders are not intended to be committed. The `/build` folder contents changes with the current environment settings and is not fit for version control. +The `/coverage` and `/.instrumented` directories are used during testing and erased with each run. Files in these folders are not intended to be committed. The `/.inlined` directory holds HTML build artifacts after they are SVG inlined but before ngtemplates runs. The `/build` folder contents changes with the current environment settings and is not fit for version control. From 23d3c3438e7d0deaa58ed5347992381ebdfd95bf Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Thu, 7 Apr 2016 12:12:03 -0500 Subject: [PATCH 07/10] rename sprite task, which was misleading, and inline SVG in templates --- grunt/watch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grunt/watch.js b/grunt/watch.js index 799300a..d227093 100644 --- a/grunt/watch.js +++ b/grunt/watch.js @@ -16,7 +16,7 @@ module.exports = { templates: { options: { cwd: "<%= ngtemplates.build.cwd %>" }, files: "<%= ngtemplates.build.src %>", - tasks: [ "ngtemplates" ] + tasks: [ "svg_inline", "ngtemplates" ] }, styles: { files: [ @@ -30,7 +30,7 @@ module.exports = { files: "<%= copy.build.src %>", tasks: [ "newer:copy:build" ] }, - sprite: { + svg: { options: { cwd: "<%= svg_sprite.use.cwd %>" }, files: "<%= svg_sprite.use.src %>", tasks: [ "svg_sprite", "svg_inline", "ngtemplates" ] From 7f94333d87d337cbfda1d80d2cf75514a7b79bf7 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 13 Apr 2016 13:39:22 -0500 Subject: [PATCH 08/10] fix templates watch --- grunt/watch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grunt/watch.js b/grunt/watch.js index d227093..c060f83 100644 --- a/grunt/watch.js +++ b/grunt/watch.js @@ -14,8 +14,8 @@ module.exports = { tasks: [ "newer:jshint:dev" ] }, templates: { - options: { cwd: "<%= ngtemplates.build.cwd %>" }, - files: "<%= ngtemplates.build.src %>", + options: { cwd: "source" }, + files: "**/*.html", tasks: [ "svg_inline", "ngtemplates" ] }, styles: { From 7c3d40baf8cd4544ecd721fcfed53e37503ba507 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 13 Apr 2016 15:23:59 -0500 Subject: [PATCH 09/10] svg_inline documentation --- CHANGELOG.md | 4 ++++ README.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d722f4..528b217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ ## Changelog +#### 7.0.0 Add svg_inline task + +- Adds support to inline the content of SVGs directly into page HTML + #### 6.1.3 Update Grunt JSHint version - Updated to support JSHint ~2.9.0, most notably the `esversion` property diff --git a/README.md b/README.md index 67cef1d..664e958 100644 --- a/README.md +++ b/README.md @@ -317,7 +317,7 @@ This list aims to be a reference and may not cover every detail of our implement Generates svg sprites and their `.css` files based on images located in the `source/images/svg-sprite` directory. The output folder is `build/svg-sprite`. - #### svg_inline - Injects SVG content referenced by SVG `` directly into the HTML document. + Injects SVG content referenced by SVG `` directly into the HTML document. This allows for the good parts of SVG `` like ability to apply CSS to SVG content, without the problematic lack of support in every version of IE. This is inline (haha) with what [GitHub is doing for SVGs](https://github.com/blog/2112-delivering-octicons-with-svg). - #### svgmin Minification for `.svg` files during deployment. From b810f95d2ca04505045782f81921aadb39f66fb3 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 13 Apr 2016 15:28:47 -0500 Subject: [PATCH 10/10] doc --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 528b217..7ecbc53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Changelog -#### 7.0.0 Add svg_inline task +#### 7.0.0 [Breaking Changes] Add svg_inline task - Adds support to inline the content of SVGs directly into page HTML