jwhitley / requirejs-rails

RequireJS support for your Rails 3 or 4 application
MIT License
592 stars 202 forks source link

Rails 4.1.10 #216

Open boxofrad opened 9 years ago

boxofrad commented 9 years ago

I've recently tried to upgrade my app from rails 4.1.4 to 4.1.10, and am now getting the following error in development:

Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( portal.js )` to `config/initializers/assets.rb` and restart your server

This asset was intentionally left out of the precompile because it's in my requirejs.yml.

Thanks :sparkling_heart:

carsomyr commented 9 years ago

@boxofrad How is it declared in your requirejs.yml?

RusDavies commented 9 years ago

Hello.

I'm having some difficulties with requirejs-rails together with recent versions of rails 4, which may include the same issue as reported by @boxofrad above.

I've created a couple of github repos, to help demonstrate working and non-working examples.

First of all, I've taken the example given at https://github.com/fs/requirejs-rails-example (which works), and adapted it for rails 4.1.4, see https://github.com/RusDavies/rails_4.1.4 . That works just fine.

Then I've attempted to adapt the same code for rails 4.2.1, see https://github.com/RusDavies/rails_4.2.1 . In this case, there are a couple of issues:

  1. In config/environment.rb, I've had to require 'yaml', otherwise requirejs-rails fails with 'uninitialized constant Requirejs::Rails::Engine::YAML (NameError)'.
  2. In config/initializers/assets.rb, I've had to add the top-level require modules to the precompile list, otherwise I get the same 'Asset filtered out and will not be served..." error as reported by @boxofrad.

With these changes, it seems to work. However, point (2) seems to go against the requirejs-rails documentation (https://github.com/jwhitley/requirejs-rails#avoid-configassetsprecompile). Moreover, this was not necessary with rails 4.1.4.

So, am I doing something wrong? Or is there some incompatibility with recent versions of Rails ?

Thanks for your help :)

boxofrad commented 9 years ago

Sorry for the late reply...

Here's my requirejs.yml

modules:
  - name: 'application'
  - name: 'portal'
  - name: 'admin'
gtd commented 9 years ago

I've also had the same Asset filtered out and will not be served: error in an app I'm upgrading from 3.2 to 4.2. This was discussed in the sprockets repo at https://github.com/rails/sprockets-rails/issues/156.

So far I've worked around this the same as @RusDavies, but of course I don't like having to maintain that parallel manifest just for development purposes.