Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "broccoli-uglify-sourcemap" to v2.0.0-beta.1 #17

Merged
merged 1 commit into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,53 @@
/* jshint node: true */
'use strict';

module.exports = {
name: 'ember-cli-uglify',

included: function(app) {
this._super.included.apply(this,arguments);

this.options = app.options;
const defaults = require('lodash.defaultsdeep');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not included in package.json

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, fixed


let defaultOptions = {
enabled: app.env === 'production',

uglify: {
compress: {
// this is adversely affects heuristics for IIFE eval
'negate_iife': false,
// limit sequences because of memory issues during parsing
sequences: 30,
},
output: {
// no difference in size and much easier to debug
semicolons: false,
},
}
};

if (app.options.sourcemaps && !this._sourceMapsEnabled(app.options.sourcemaps)) {
defaultOptions.uglify.sourceMap = false;
}

this._options = defaults(app.options['ember-cli-uglify'] || {}, defaultOptions);
},

_sourceMapsEnabled(options) {
if (options.enabled === false) {
return false;
}

let extensions = options.extensions || [];
if (extensions.indexOf('js') === -1) {
return false;
}

return true;
},

postprocessTree: function(type, tree) {
if(this.options.minifyJS.enabled === true && type === 'all') {
var options = this.options.minifyJS.options || {};
options.sourceMapConfig = this.options.sourcemaps;
return require('broccoli-uglify-sourcemap')(tree, options);
if (this._options.enabled === true && type === 'all') {
return require('broccoli-uglify-sourcemap')(tree, this._options);
} else {
return tree;
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"before": "broccoli-asset-rev"
},
"dependencies": {
"broccoli-uglify-sourcemap": "^1.0.0"
"broccoli-uglify-sourcemap": "^2.0.0-beta.1",
"lodash.defaultsdeep": "^4.6.0"
}
}