Question

I'm using Restangular with Rails 4, and I wish to tell rails to skip precompiling Restangular as I'm using the official minified version which doesn't mangle the variable names to prevent problems with Angular dependency injection.

Here's my application.js.coffee:

#= require jquery
#= require jquery_ujs
#= require unstable/angular
#= require underscore
#= require_self
#= require_tree ./vendor
#= require_tree ./configs
#= require_tree ./models
#= require_tree ./directives
#= require_tree ./filters
#= require_tree ./controllers
#= require_tree ./misc

window.app = angular.module "myApp", ["restangular"]

The minified restangular.min.js file lives under the "javascripts/vendor" directory. It needs to be loaded after Angular and before all my controllers and models and stuff are loaded.

How can I tell Rails asset pipeline to skip minifying the restangular file and still load it the correct order?

Thanks!

Edit:

I found the solution and answered my own question.

Was it helpful?

Solution 2

Solution:

I was using ngmin-rails gem to avoid problems with asset pipeline(Uglifier mangle) for my angular code. I never knew that third party libraries like restangular can also go through ngmin-rails. So I added the following line at the top of the pre-minified restangular.min.js file and it works like a charm!

var app = angular.module("myApp");

BTW, I also removed this line from my application layout html: <%= javascript_include_tag "vendor/restangular.min.js" %>

OTHER TIPS

I'm also looking for a solution to this problem -- skipping minification of 3rd party libraries -- but in the meantime:

# config/environments/production.rb
config.assets.js_compressor = Uglifier.new(:mangle => false)

Then switch your vendor lib to the unminified source and let Rails crunch it until you/we find a better option.

More Uglifier options here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top