From 6e074188d4aadfe02e428a365f628f4d2e871327 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 25 Mar 2013 14:22:09 -0400 Subject: [PATCH 1/4] Grunt: generate source maps when compressing --- Gruntfile.js | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8bdadd0d..ff430a9a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -79,7 +79,10 @@ module.exports = function(grunt) { }, uglify: { options: { - preserveComments: "some" + preserveComments: "some", + sourceMap: function (filename) { + return filename.replace(/\.js$/, '.js.map'); + } }, openseadragon: { src: [ distribution ], diff --git a/package.json b/package.json index 3d84b367..16464e41 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "grunt-contrib-compress": "~0.5.0", "grunt-contrib-concat": "~0.1.2", "grunt-contrib-jshint": "~0.1.1", - "grunt-contrib-uglify": "~0.1.1", + "grunt-contrib-uglify": "~0.2.0", "grunt-contrib-qunit": "~0.2.0", "grunt-contrib-connect": "~0.1.2", "grunt-contrib-watch": "~0.2.0", From ae881689ec72b244129acfe58a98a1456dceb8f0 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 26 Mar 2013 15:45:22 -0400 Subject: [PATCH 2/4] Strip build prefix from sourceMappingURL (see #51) Previously the sourceMappingURL would be prefixed with "build/openseadragon/" --- Gruntfile.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index ff430a9a..d8f5364c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -82,7 +82,10 @@ module.exports = function(grunt) { preserveComments: "some", sourceMap: function (filename) { return filename.replace(/\.js$/, '.js.map'); - } + }, + sourceMappingURL: function (filename) { + return filename.replace(/\.js$/, '.js.map').replace('build/openseadragon/', ''); + }, }, openseadragon: { src: [ distribution ], From b87de8e6c612ce2b68f53e357df65cf405fc0770 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 9 Apr 2013 14:44:08 -0400 Subject: [PATCH 3/4] Grunt: normalize build paths The sourcemaps included build/openseadragon/ in the paths. Since grunt lacks a standard way to replace text in files, I semi-randomly picked grunt-text-replace. --- Gruntfile.js | 16 +++++++++++++++- package.json | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index d8f5364c..1c9f83c8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,6 +10,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-contrib-watch"); grunt.loadNpmTasks("grunt-contrib-clean"); grunt.loadNpmTasks("grunt-git-describe"); + grunt.loadNpmTasks('grunt-text-replace'); // ---------- var packageJson = grunt.file.readJSON("package.json"), @@ -77,6 +78,18 @@ module.exports = function(grunt) { dest: distribution } }, + replace: { + cleanPaths: { + src: ['build/openseadragon/*.map'], + overwrite: true, + replacements: [ + { + from: /build\/openseadragon\//g, + to: '' + } + ] + } + }, uglify: { options: { preserveComments: "some", @@ -196,7 +209,8 @@ module.exports = function(grunt) { // Build task. // Cleans out the build folder and builds the code and images into it, checking lint. grunt.registerTask("build", [ - "clean:build", "jshint:beforeconcat", "git-describe", "concat", "jshint:afterconcat", "uglify", "copy:build" + "clean:build", "jshint:beforeconcat", "git-describe", "concat", "jshint:afterconcat", + "uglify", "replace:cleanPaths", "copy:build" ]); // ---------- diff --git a/package.json b/package.json index 16464e41..01947432 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "grunt-contrib-connect": "~0.1.2", "grunt-contrib-watch": "~0.2.0", "grunt-contrib-clean": "~0.4.0", - "grunt-git-describe": "~2.0.0" + "grunt-git-describe": "~2.0.0", + "grunt-text-replace": "~0.3.2" }, "scripts": { "test": "grunt test" From 3c66c3b8e2a65efffad00cc8eeb41fd38dab2485 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 19 Jun 2013 14:30:44 -0400 Subject: [PATCH 4/4] Update to grunt-contrib-uglify 0.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 01947432..5f9dd1a4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "grunt-contrib-compress": "~0.5.0", "grunt-contrib-concat": "~0.1.2", "grunt-contrib-jshint": "~0.1.1", - "grunt-contrib-uglify": "~0.2.0", + "grunt-contrib-uglify": "~0.2.2", "grunt-contrib-qunit": "~0.2.0", "grunt-contrib-connect": "~0.1.2", "grunt-contrib-watch": "~0.2.0",