3.2.4+ assets:precompile regression #6737

Closed
rwz opened this Issue Jun 14, 2012 · 12 comments

Projects

None yet

9 participants

@rwz
rwz commented Jun 14, 2012

Starting from 3.2.4 Rails assets:precompile task just ignores files with names like 'index.(css|js)'.

Because of #3993 I had to manually add index files to config.assets.precompile array. Now it just skips such files. So, application that was working perfectly fine on 3.2.3 throws AssetNotPrecompiledError constantly.

Here is the showcase: https://github.com/rwz/rails-assets-degradation-showcase

The public folder contains assets compiled on 3.2.3 and on current 3.2.6. The difference is that folder was completely ignored in 3.2.6.

@route
route commented Jun 15, 2012

Nice showcase @rwz, I've checked your app and I see that you use [ 'folder/index.js' ] but it had been workaround when rake task was skiping index files, but now you can just write [ 'folder.js' ] and it will be compiled. Another case when debug option is off and you are writing javascript_include_tag "folder", the script tag will be <script src="/assets/folder.js" type="text/javascript"></script> also as and precompiled. I think it's not regression /cc @drogus @guilleiguaran

@rwz
rwz commented Jun 16, 2012

This is something that was working before and not working now, so it is clearly a regression for me. Also, i'm explicitly adding index.js file which exists AND this code works in development but not in production. I think this is both misleading and inconsistent.

What i think should actually happen here is this:

  • if this file like folder/index.js explicitly added to assets.precompile array, it should be compiled as folder/index.js
  • if the file added is folder.js, it should first try folder.js, then folder/index.js and compile it as folder.js
@route
route commented Jun 16, 2012

@rwz I've got your point, I think it justified, I can take a look, but it would be nice to hear core team opinion.

@edgard
edgard commented Jun 17, 2012

Also breaks if you use *.js and *.css for the asset list. It loads everything but the index.(js|css).

@Coomer
Coomer commented Jun 18, 2012

I found the same as @edgard. I was using *.js for the asset precompile list, and found that some_folder/index.js was changed to some_folder.js once precompiled after upgrading from 3.2.3 to 3.2.6.

We weren't expecting this change, and it broke our production site. Only after scrambling to fix this issue and researching further did our team find this documentation detailing the special behavior of assets named index.js/css.

@ncdc
ncdc commented Jul 11, 2012

This is hitting us too. We were on 3.2.3 and do things like

javascript_include_tag 'runs/index'

and we have app/assets/javascripts/runs/index.js.coffee. It is not a manifest file but contains actual logic. Unfortunately for us, it's getting compiled to runs.js instead of runs/index.js.

Any chance this will be fixed, or is it truly not a bug (because of the index.js manifest feature of Sprockets)?

@dkharrat

I recently upgraded to 3.2.8 and encountered this issue. I was able to solve it by changing this in the production.rb config file:

config.assets.precompile += ['folder']

to

config.assets.precompile += ['folder.js']

and then using it in the specific views through:

javascript_include_tag 'folder'

where folder is the folder name containing the index.js file. Basically, adding the '.js' extension to the folder name in the precompile config did the trick. I don't why this behavior changed; the previous one made more sense to me.

@jeremy
Member
jeremy commented Oct 2, 2012

Fixed @ 19987b6

@jeremy jeremy closed this Oct 2, 2012
@cvandermey

question: I noted that when I created an "application-all.css.scss" file in /assets/stylesheets, and my "application.css.scss" file was in /assets/stylesheets/all, the command in my config.assets.precompile -

config.assets.precompile += %w( application-all.css.scss application-print.css.scss application-ie.css.scss)

Was ignored. Rather, I needed to remove the ".scss" extension, even though the files end in ".scss". The following works:

config.assets.precompile += %w( application-all.css application-print.css application-ie.css)

This seems to refute the statement in the comments in 3.2.8

"# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)"

Since the .scss was not added.

@rwz
rwz commented Oct 23, 2012

@cvandermey scss is a preproccessor in that case. For assets pipeline this file's called application-all.css. It doesn't care if it's compiled out of SCSS or SASS or even LESS.

The same with javascript. If you name your file my-file.js.coffee, you'll need to add my-file.js to the config.assets.precompile for assets pipeline to recognize it properly.

@cvandermey

My comment was that the comment preceding this line in the production.rb
file was not very clear. Perhaps we could clarify it for the n00bs?

C.

On Mon, Oct 22, 2012 at 9:36 PM, Pavel Pravosud notifications@github.comwrote:

@cvandermey https://github.com/cvandermey scss is a preproccessor in
that case. For assets pipeline this file's called application-all.css. It
doesn't care if it's compiled out of SCSS or SASS or even LESS.

The same with javascript. If you name your file my-file.js.coffee, you'll
need to add my-file.js to the config.assets.precompile for assets
pipeline to recognize it properly.


Reply to this email directly or view it on GitHubhttps://github.com/rails/rails/issues/6737#issuecomment-9690412.

Chris Vander Mey
206.395.9209
CEO, Scaled Recognition, Inc. http://bit.ly/TZzEZe
blog http://bit.ly/PNb38C - Read The Book http://amzn.to/UdVaLG! - t
witter http://bit.ly/QhJof3

@steveklabnik
Member

Questions are best asked on StackOverflow, not on Issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment