0

I'm having problems precompiling my assets in a Rails 4 app. I followed the steps in this question to set up two different files in my asset pipeline that act as asset manifest files. In particular, in my /app/assets/javascript directory, I have two files, application.js and meeting_handout.js that act as manifest files. When I run rake assets:precompile, however, only the assets referenced from application.js are precompiled. I end up with the file public/assets/application-HASH.css being generated, but not the file public/assets/meeting-handout-HASH.css. What can I do to fix this?

The research I've done so far says to make sure that in config/application.rb, I include the following line:

config.assets.precompile += %w( meeting_handout.js )

My appliation.rb does in fact have that line, but I'm still not getting the behavior I'm expecting.

Community
  • 1
  • 1
Kevin
  • 14,655
  • 24
  • 74
  • 124

2 Answers2

1

If you haven't already, you should also be sure to modify application.js as suggested in the linked answer (to either stub meeting_handout.js, or rearrange shared assets, as the additional links in the linked answer detail).

TK-421
  • 10,598
  • 3
  • 38
  • 34
  • I followed the steps in the linked question to a T. (I actually wrote it after figuring out how to do everything on my own. Afterwards, I wrote exactly what I did, partly so I had an easy way to summarize what I did in case I needed to explain myself in the future!) – Kevin Dec 21 '14 at 00:19
  • So `application.js` has definitely been modified? (That source wasn't included in your question, only `application.rb`, so just making sure! And if so, you might want to include that in your post as well.) – TK-421 Dec 21 '14 at 00:21
  • `application.js` has been modified, but `meeting_handout.css`, a file referenced by `meeting_handout.js` with a `//=require` line, has been modified too. I expect that when I run `rake assets:precompile`, my updated `meeting_handout.css` is precompiled into `public/meeting_handout-HASH.css`. – Kevin Dec 21 '14 at 00:23
  • I see what you're saying. Yes, `application.js` has been modified to include `//= stub meeting_handout`. – Kevin Dec 21 '14 at 00:49
1

In config/application.rb, I changed

config.assets.precompile += %w( meeting_handout.js )

to

config.assets.precompile += %w( meeting_handout.css )

I wasn't using the meeting_handout.js file for anything besides referencing meeting_handout.css, and after looking at it more closely, it looks like rake assets:precompile was only ever compiling the .js file. Telling Rails to compile the .css file worked like I wanted it to.

Kevin
  • 14,655
  • 24
  • 74
  • 124