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

minifyJS.enabled option in ember-cli-build not working #7445

Closed
cdatehortuab opened this issue Nov 15, 2017 · 11 comments
Closed

minifyJS.enabled option in ember-cli-build not working #7445

cdatehortuab opened this issue Nov 15, 2017 · 11 comments

Comments

@cdatehortuab
Copy link

cdatehortuab commented Nov 15, 2017

Hello,

I'm having an issue when build my ember project.

The problem is that ember-cli is ignoring the minifyJS.enabled option.

It only takes into account the environment, not my custom option.

If I build for 'development', using in my ember-cli-build.js file:
minifyJS: { enabled: true },,
the JavaScript files should be minified but they are not.

And, if I build for 'production', using in my ember-cli-build.js file:
minifyJS: { enabled: false },,
the JavaScript files should not be minified but they are.

Thanks.

Output from ember version --verbose && npm --version && yarn --version:

ember-cli: 2.16.2
http_parser: 2.7.0
node: 6.12.0
v8: 5.1.281.108
uv: 1.15.0
zlib: 1.2.11
ares: 1.10.1-DEV
icu: 58.2
modules: 48
openssl: 1.0.2m
os: linux x64
3.10.10
1.3.2
@twokul
Copy link
Contributor

twokul commented Nov 15, 2017

@cdatehortuab just to be clear, your ember-cli-build.js contains:

// ember-cli-build.js
const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  const app = new EmberApp(defaults, {
    minifyJS: {
      enabled: true
    }
  });

  //...
  return app.toTree();
};

and it doesn't minify files?

@cdatehortuab
Copy link
Author

@twokul No, it doesn't.

It is as if it was only taking into account the environment for which I'm building and not my config.

@twokul
Copy link
Contributor

twokul commented Nov 15, 2017

@cdatehortuab can you put together a reproduction?

@cdatehortuab
Copy link
Author

First this is the output of ember version --verbose && npm --version && yarn --version

ember-cli: 2.16.2
http_parser: 2.7.0
node: 6.12.0
v8: 5.1.281.108
uv: 1.15.0
zlib: 1.2.11
ares: 1.10.1-DEV
icu: 58.2
modules: 48
openssl: 1.0.2m
os: linux x64
3.10.10
1.3.2

I generated a new ember project with ember new ember-test
Then, I put in ember-cli-build.js file:

// ember-cli-build.js
/* eslint-env node */
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    minifyJS: {
      enabled: true
    }
  });

  return app.toTree();
};

After that I ran ember build --env=development and I got that .js files in dist directory are not minified.

Then, I changed the ember-cli-build.js file to:

// ember-cli-build.js
/* eslint-env node */
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    minifyJS: {
      enabled: false
    }
  });

  return app.toTree();
};

And when I ran ember build --environment=production command, I got minified .js files.

So that option is being ignored by ember-cli.

I hope it was clear.

Greetings, thanks.

@axiomabsolute
Copy link

I went ahead and created a minimal example verifying the issue.

Minimal Ember-CLI Example

Clone the repo, run ember build -prod and note that the output is still minified, despite minifyJS: { enabled: false } being set in the ember-cli-build.js file. That is the only change I made to the basic ember init setup.

@axiomabsolute
Copy link

I believe this is related to the following change in the broccoli-uglify-sourcemap plugin:

ember-cli/broccoli-terser-sourcemap#49

Based on this, the options hash format is quite different from the one posted in the docs. The docs currently say:

screen shot 2017-11-16 at 12 19 00 pm

however I believe the plugin now expects a different format. The following ember-cli-build.js appears to work as expected:

/* eslint-env node */
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    /*
     * this looks to be broken!
    minifyJS: {
      enabled: false
    },
    */
    'ember-cli-uglify': {
      enabled: true,
      uglify: {
        // compress: true,
        // sourceMap: true,
        mangle: false, // defaults to true
      }
    },
  });

  return app.toTree();
};

@Turbo87
Copy link
Member

Turbo87 commented Nov 20, 2017

@axiomabsolute thanks for investigating this. could you open an issue on the https://github.com/ember-cli/broccoli-uglify-sourcemap/issues repo for this? and if you have a bit of time it would be awesome if you could come up with a failing test for it that reproduces the problem.

@c-emil
Copy link

c-emil commented Jun 14, 2018

Has anyone investigated this issue further? I've run into the same issue today and it's been half year since this issue was submitted. It would be nice to update ember-cli docs, what do you think?

@ultimatemonty
Copy link

another ping!

Trying to debug some issues that only occur in production and wanting to ship unminified, fingerprinted assets. ember-cli (or broccoli-uglify-sourcemaps?) is not respecting minifyJS: { enabled: false } when running ember build --environment=production

@Turbo87
Copy link
Member

Turbo87 commented Oct 10, 2018

@ultimatemonty have a look at https://github.com/ember-cli/ember-cli-uglify#usage. it describes how to disable the JS minification step.

@locks
Copy link
Contributor

locks commented Feb 10, 2022

Closing as no longer relevant due to the migration from uglify to terser.

@locks locks closed this as completed Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants