-
Notifications
You must be signed in to change notification settings - Fork 149
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
Issue while compressing JS files with the Asset Pipeline #13
Comments
Yes I ran into the same issue when deploying on Heroku. I had to:
Letting Heroku run the asset precompile command even with I don't know much |
thanks, but it did't works for me. exactly same steps, but i'm precompiling in the server (is a VPS not heroku). The only that works for me is to create links to the original widget: r.html -> /usr/local/rvm/gems/ruby-1.9.3-p448/gems/dashing-rails-2.1.1/app/views/dashing/widgets/number.html |
This is very weird, you should be able to control how the asset pipeline compress your JS files. It's not an issue directly related to dashing-rails gem sicne it would work nicely if the JS files are just compressed but variables name beeing not modified. Please let me know if you figure out a way to make it work. |
Its not ideal but I had the same issue, I fixed it (temporarily with) class NoCompressor
def compress(string)
string
end
end at the top of production.rb then config.assets.js_compressor = NoCompressor.new basically, disable js compression (I didn't look very hard to try and find a proper way to disable it) a hack for sure but it got me one step further :) |
Thanks for the feedback! |
Let me close the issue since it's not really a bug from the gem and we now have identified where does the issue come from. Please keep us posted we you find anything. |
IMHO is not good idea to lose this bug. Is easy to find it if it is open, and this workaround disable compression in the whole rails app, not only dashing, so it is actually a requirement to use rails-dashing. |
Yes I see, i'll digg into this issue to see what can be done. |
Hi guys, I've run in to this problem today. I'm working on setting up dashing-rails at the moment so if anyone can provide me with any info I can take a look at fixing it. Ta, |
Basically the issue comes from the JS compressor when precompiling the assets on production. The default JS compressor seems to also change JS variables and class names (from Since the widget's name are used to fetch their HTML template from the server (making a GET request), having their name changed cause the issue. In order to get around this issue for the moment, you need to change the default JS compressor used when compressing the assets. I have done the above for the heroku demo application by following the following steps:
|
I will look more closely to this issue since I was recently told that the default JS compressor should not change |
If you guys want to take a look at it. Here is where I use the JS widget name to get its HTML template on the server side https://github.com/gottfrois/dashing-rails/blob/master/app/controllers/dashing/widgets_controller.rb#L29 All we have to do is to make sure the name coming from the |
Thanks @gottfrois. I'll have a look at this once I'm back in the office. |
Seems that by default uglifier will mangle variable and function names. The documentation seems to suggest that you can do something like config.assets.js_compressor = Uglifier.new(mangle: false) # Uglifier.new(:mangle => false) for old Ruby https://github.com/lautis/uglifier#usage I will run this when I get a chance but feel free to jump in there before me. |
I'll try that tonight, thanks for digging in to this issue. |
Ok setting Thanks for looking at it. |
Sorry for the long wait. Nothing comes to mind immediately. I won't have much time to look at this in the coming weeks but if you leave any thoughts on this thread I'll investigate them once I'm back on the dashboard project. Thanks. |
@brightbits thanks for your tip! This was perfect for my application since it's just a rest api. |
Hi,
I'm trying to run rails-dashing under passenger-nginx and i Get this errors:
GET http://foo.com/dashing/widgets/r.html 500 (Internal Server Error) application-3587576a36c1ab2a24c5687247faf363.js:3
Uncaught Error: Could not load view from /r application-3587576a36c1ab2a24c5687247faf363.js:13
GET http://foo.com/dashing/widgets/u.html 500 (Internal Server Error) application-3587576a36c1ab2a24c5687247faf363.js:3
Uncaught Error: Could not load view from /u application-3587576a36c1ab2a24c5687247faf363.js:13
Of course widgets 'u' and 'r' doesn't exist and are not defined anywhere
I set the js compressosr as YUI and even leave raisl to serve the assets in real time (like in dev) but not lucky.
I also added the options suggested to run it under apache:
rails_app_spawner_idle_time 0;
passenger_min_instances 1;
Any clue will be welcome
TIA
The text was updated successfully, but these errors were encountered: