diff --git a/Gruntfile.js b/Gruntfile.js index 4ed45888..c9166de7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -151,13 +151,13 @@ module.exports = function(grunt) { grunt.registerTask('createDistVersion', filterAvailable([ 'useminPrepare', // Configures concat, cssmin and uglify 'concat', // Combines css and javascript files - + 'copy:originals', 'cssmin', // Minifies css 'uglify', // Minifies javascript 'imagemin', // Optimizes image compression // 'svgmin', 'copy:dist', // Copies files not covered by concat and imagemin - + 'clean:tmp', 'rev', // Appends 8 char hash value to filenames 'usemin', // Replaces file references 'htmlmin:dist' // Removes comments and whitespace diff --git a/app/initializers/tracker.js b/app/initializers/tracker.js index af147333..9684775b 100644 --- a/app/initializers/tracker.js +++ b/app/initializers/tracker.js @@ -8,9 +8,9 @@ export default { window.Raygun = null; // Track hosted errors only - /*if (window.ENV.isDevelopment || window.ENV.selfHosted) { + if (window.ENV.isDevelopment || window.ENV.selfHosted) { return; - }*/ + } application.deferReadiness(); diff --git a/package.json b/package.json index 6176b0c6..9fc647af 100644 --- a/package.json +++ b/package.json @@ -33,13 +33,11 @@ "grunt-contrib-concat": "~0.5.0", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-jshint": "~0.8.0", - "grunt-contrib-uglify": "~0.6.0", "grunt-contrib-cssmin": "~0.6.2", "grunt-preprocess": "~3.0.1", "grunt-es6-module-transpiler": "~0.6.0", "grunt-concat-sourcemap": "~0.4.0", "grunt-concurrent": "~0.4.3", - "grunt-usemin": "~0.1.13", "grunt-rev": "~0.1.0", "grunt-ember-templates": "~0.4.23", "ember-template-compiler": "~1.8.0", @@ -51,7 +49,9 @@ "loom": "~3.1.2", "connect-livereload": "~0.3.1", "grunt-contrib-sass": "~0.7.2", - "grunt-es6-import-validate": "0.0.6" + "grunt-es6-import-validate": "0.0.6", + "grunt-contrib-uglify": "~0.7.0", + "grunt-usemin": "~3.0.0" }, "dependencies": { "gapitoken": "~0.1.0", diff --git a/tasks/options/clean.js b/tasks/options/clean.js index 36b89bf7..32c3876d 100644 --- a/tasks/options/clean.js +++ b/tasks/options/clean.js @@ -1,4 +1,5 @@ module.exports = { 'debug': ['tmp'], - 'dist': ['tmp', 'dist'] + 'dist': ['tmp', 'dist'], + 'tmp' : ['.tmp'] }; diff --git a/tasks/options/copy.js b/tasks/options/copy.js index 27f99918..7f139ead 100644 --- a/tasks/options/copy.js +++ b/tasks/options/copy.js @@ -83,4 +83,17 @@ module.exports = { dest: 'dist/' }] }, + + originals: { + files: [{ + expand: true, + cwd: '.tmp/concat/assets', + src: [ + '**', + '!**/*.{css}' + ], + filter: 'isFile', + dest: 'dist/assets' + }] + } }; diff --git a/tasks/options/uglify.js b/tasks/options/uglify.js new file mode 100644 index 00000000..9afbad81 --- /dev/null +++ b/tasks/options/uglify.js @@ -0,0 +1,5 @@ +module.exports = { + options: { + sourceMap: true + } +}; diff --git a/tasks/options/useminPrepare.js b/tasks/options/useminPrepare.js index 6e5f58c7..8c5426ec 100644 --- a/tasks/options/useminPrepare.js +++ b/tasks/options/useminPrepare.js @@ -1,6 +1,39 @@ module.exports = { html: 'tmp/result/index.html', options: { - dest: 'dist/' + dest: 'dist/', + flow: { + steps: { + js: ['concat', 'uglifyjs'], + css: ['concat', 'cssmin'] + }, + post: { + js: [{ + name: 'concat', + createConfig: function(context, block) { + context.options.generated.files.forEach(function(file) { + if(file.dest.indexOf('.min.js') !== -1) { + file.dest = file.dest.replace('.min.js', '.js'); + } + }) + } + }, { + name: 'uglify', + createConfig: function(context, block) { + context.options.generated.files.forEach(function(file) { + if(file.src.indexOf('.min.js') !== -1) { + file.src = file.src.replace('.min.js', '.js'); + } else if (Array.isArray(file.src)) { + var newArray = []; + file.src.forEach(function(realsrc) { + newArray.push(realsrc.replace('.min.js', '.js')); + }) + file.src = newArray; + } + }) + } + }] + } + } } }; diff --git a/tasks/push-production.js b/tasks/push-production.js index 74135c6f..9e66b01d 100644 --- a/tasks/push-production.js +++ b/tasks/push-production.js @@ -13,14 +13,31 @@ module.exports = function(grunt) { grunt.registerTask('push-prod', function() { var done = this.async(); var files = wrench.readdirSyncRecursive(distDir); - var uploadFunctions = []; - files.forEach(function(file) { var source = distDir + file; if(!fs.lstatSync(source).isDirectory()) { + + // fix source map + if(file.indexOf('.min.js.map') !== -1) { + var contents = JSON.parse(fs.readFileSync(source).toString()); + + var newSources = []; + contents.sources.forEach(function(src) { + var parts = src.split('/'); + var newSource = parts[parts.length - 1]; + + newSources.push(newSource); + }) + + contents.sources = newSources; + + fs.writeFileSync(source, JSON.stringify(contents)); + } + + if(file.indexOf('.vendor.min.js') !== -1) { uploadFunctions.push(function(step) { grunt.log.success('uploading ' + source);