Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
sourcemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
LtSquigs committed Feb 3, 2015
1 parent 5e07c64 commit e8f3baf
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/initializers/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion tasks/options/clean.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
'debug': ['tmp'],
'dist': ['tmp', 'dist']
'dist': ['tmp', 'dist'],
'tmp' : ['.tmp']
};
13 changes: 13 additions & 0 deletions tasks/options/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,17 @@ module.exports = {
dest: 'dist/'
}]
},

originals: {
files: [{
expand: true,
cwd: '.tmp/concat/assets',
src: [
'**',
'!**/*.{css}'
],
filter: 'isFile',
dest: 'dist/assets'
}]
}
};
5 changes: 5 additions & 0 deletions tasks/options/uglify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
options: {
sourceMap: true
}
};
35 changes: 34 additions & 1 deletion tasks/options/useminPrepare.js
Original file line number Diff line number Diff line change
@@ -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;
}
})
}
}]
}
}
}
};
21 changes: 19 additions & 2 deletions tasks/push-production.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e8f3baf

Please sign in to comment.