-
Notifications
You must be signed in to change notification settings - Fork 205
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
add note on minification #124
Conversation
|
||
in your `config/environments/production.rb` file. Disabling in Ember | ||
is the better route if it works for you, but it may be more fragile in | ||
the case of javascript errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this part. How can it be more fragile? Care to elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your guess is as good as mine. :) I get this error in an app:
rake aborted!
ExecJS::ProgramError: Unexpected token: punc (:) (line: 1, col: 10, pos: 10)
Error
at new JS_Parse_Error (/tmp/execjs20150321-24731-1hyu7atjs:2359:10623)
at js_error (/tmp/execjs20150321-24731-1hyu7atjs:2359:10842)
at croak (/tmp/execjs20150321-24731-1hyu7atjs:2359:19086)
at token_error (/tmp/execjs20150321-24731-1hyu7atjs:2359:19223)
at unexpected (/tmp/execjs20150321-24731-1hyu7atjs:2359:19311)
at semicolon (/tmp/execjs20150321-24731-1hyu7atjs:2359:19784)
at simple_statement (/tmp/execjs20150321-24731-1hyu7atjs:2359:22580)
at /tmp/execjs20150321-24731-1hyu7atjs:2359:20274
at /tmp/execjs20150321-24731-1hyu7atjs:2359:19957
at block_ (/tmp/execjs20150321-24731-1hyu7atjs:2359:24599)
(in /home/egh/c/tahi/tmp/ember-cli-cd98e71c-ad5a-4b81-85de-a24baaf26e75/assets/tahi/ember-data.js.map)new JS_Parse_Error ((execjs):2359:10623)
when I disable minifyJS in ember and use uglify in rails. I'll try to track it down, but it's pretty unclear to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Will investigate this before merging the PR.
Other than my comment above LGTM. |
Thanks! |
Disabling in ember-cli can be done automatically by the addon. [Edit]: @egh I think the readme should still be updated to show that you can disable this in Rails land. And I'd be interested in working with you on a PR for ember-cli-rails-addon also, if you wanna. Should be very similar to this line:
|
@rondale-sc That might be useful. I'm not sure if there is a one size fits all solution, though. Whether minification is better done in ember or rails might depend on the nature of your app. Another issues is source maps. I'm still trying to get source maps to work in production with an ember-cli-rails app. [edit] Perhaps a good start would be to add a warning if you are minifying your code twice. |
@egh I was attempting to use the I found this issue: emberjs/ember-rails#428 It seems that tossing this in an initializer fixes the issue: Rack::Mime::MIME_TYPES.merge!(".map" => "text/plain") It should probably be application/json, though. See http://stackoverflow.com/questions/18809567/what-is-the-correct-mime-type-for-min-map-javascript-source-files#18809594. However, there's also this issue: sstephenson/sprockets#400. It seems to suggest that map files shouldn't be asset path at all. |
@rzane adding the
and keep the Rails JS compressor turned on. Builds are taking me about 20-30 seconds. |
We're sorry that this issue has sat for so long. The project is now maintained by thoughtbot, and we're declaring an issue bankruptcy of sorts. We're closing this issue. If what you've described is still a problem, please comment on this issue and we'll reopen. @rondale-sc were we able to modify https://github.com/rondale-sc/ember-cli-rails-addon to handle this automatically? Thanks for your patience. |
It is still an issue: javascript assets are being minified by ember and by rails asset pipeline in the default setup. This is a problem because a) it breaks sourcemaps and b) it is slow. How to replicate: do the following (as recommended by the README): rails new foo
cd foo
echo "gem 'ember-cli-rails', github: 'thoughtbot/ember-cli-rails'" >> Gemfile
bundle install
rails generate ember-cli:init
mkdir frontend
cd frontend
ember init
npm install --save-dev [email protected]
cd .. Now, running: This behavior can be tested by suspending ( |
@egh thanks for following up. Hopefully we'd be able to set this automatically through https://github.com/rondale-sc/ember-cli-rails-addon. @rondale-sc is that something that's in the works? If not, @egh would you mind opening a PR against that project? |
@seanpdoyle A decision would need to made about whether it is better for ember or the rails asset pipeline to handle this. I'm not really sure if there is a universally better choice, or if there is, which it is. But I'm happy to do what I can. |
My opinion is that it would be better for the ember addon to handle turning uglification / minification off. Leaving it enabled Rails-side lets developers continue to minify/uglify their server-side assets. Would you agree? |
When precompiling assets in production, we ensure that we are not minifying the JavaScript assets twice. Duplicating minification can slow down assets precompilation considerably. Closes [tricknotes/ember-cli-rails#124][124] and [tricknotes/ember-cli-rails#123][123]. [123]: tricknotes/ember-cli-rails#123 [124]: tricknotes/ember-cli-rails#124
That sounds reasonable. I'll file a pull request. |
It seems you were way ahead of me. :) I guess we can close this pull request, then? Thank you for your work on this! |
@egh I've gone back on forth on where (and whether or not) minification should happen. In the meantime, I think your PR make a lot of sense. Would you mind updating the reference to Also, I think it makes sense to omit
since we really don't know which side of the pipeline is better suited for minifcation. What do you think? |
Oh, sorry, I thought rondale-sc/ember-cli-rails-addon#16 was merged. I will update this PR. |
Updated. |
Merged in ef0fc67 |
Thanks! |
Given the outcome of [#123] and [#124], we don't take a stand on where minification should happen. However, to make sure that Heroku deployments don't take too long, the generator can disable Rails-side minification. The benefit of doing this in the generator (as opposed to automatically in [the addon]) is that the change will introduce diff noise, which is explicit and easy to back out of. [#123]: #123 [#124]: #124 [the addon]: https://github.com/rondale-sc/ember-cli-rails-addon/blob/2f2a47efe6e81a2bcd43ec9ff0f89fc18bed5a03/index.js#L25-L32
Given the outcome of [#123] and [#124], we don't take a stand on where minification should happen. However, to make sure that Heroku deployments don't take too long, the generator can disable Rails-side minification. The benefit of doing this in the generator (as opposed to automatically in [the addon]) is that the change will introduce diff noise, which is explicit and easy to back out of. [#123]: #123 [#124]: #124 [the addon]: https://github.com/rondale-sc/ember-cli-rails-addon/blob/2f2a47efe6e81a2bcd43ec9ff0f89fc18bed5a03/index.js#L25-L32
When precompiling assets in production, we ensure that we are not minifying the JavaScript assets twice. Duplicating minification can slow down assets precompilation considerably. Closes [tricknotes/ember-cli-rails#124][124] and [tricknotes/ember-cli-rails#123][123]. [123]: tricknotes/ember-cli-rails#123 [124]: tricknotes/ember-cli-rails#124
When precompiling assets in production, we ensure that we are not minifying the JavaScript assets twice. Duplicating minification can slow down assets precompilation considerably. Closes [tricknotes/ember-cli-rails#124][124] and [tricknotes/ember-cli-rails#123][123]. [123]: tricknotes/ember-cli-rails#123 [124]: tricknotes/ember-cli-rails#124
Given the outcome of [#123] and [#124], we don't take a stand on where minification should happen. However, to make sure that Heroku deployments don't take too long, the generator can disable Rails-side minification. The benefit of doing this in the generator (as opposed to automatically in [the addon]) is that the change will introduce diff noise, which is explicit and easy to back out of. [#123]: #123 [#124]: #124 [the addon]: https://github.com/rondale-sc/ember-cli-rails-addon/blob/2f2a47efe6e81a2bcd43ec9ff0f89fc18bed5a03/index.js#L25-L32
Given the outcome of [#123] and [#124], we don't take a stand on where minification should happen. However, to make sure that Heroku deployments don't take too long, the generator can disable Rails-side minification. The benefit of doing this in the generator (as opposed to automatically in [the addon]) is that the change will introduce diff noise, which is explicit and easy to back out of. [#123]: #123 [#124]: #124 [the addon]: https://github.com/rondale-sc/ember-cli-rails-addon/blob/2f2a47efe6e81a2bcd43ec9ff0f89fc18bed5a03/index.js#L25-L32
See #123