documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

Generated files js/css have current time file times #33

Closed dmitry closed 14 years ago

dmitry commented 14 years ago

May be it's possible somehow to do it in that way, that when file is generating it will have max mtime from all the files that it was generated from.

For example, we have two JS files, we generated using jammit a new concatenated and compressed (packaged) .JS file, then we executing jammit again, and this file will have the previous mtime, but not the Time.now (it is how it behave right now).

Extended example and realizations you can find here: http://github.com/pyromaniac/smart_link_tags/blob/master/lib/smart_link_tags.rb#L41

Thanks, Dmitry

jashkenas commented 14 years ago

Hi Dmitry.

This is happening because the jammit command (by default) doesn't rebuild packages that haven't changed -- to help keep builds as fast as possible. If you'd like to force all of the packages to rebuild, updating all of the timestamps, run:

jammit --force

Write back if that doesn't work for you.

dmitry commented 14 years ago

Hi,

Yes, you are right, command jammit doesn't touch files, if source files wasn't changed. But I have another problem - on the production I have completely new current dir exported from git repo, and no assets directory from the previous deployed version.

So solution is to: move files from the previous deployed version to the current one (and run jammit on top of that files)?

But maybe it's better to check (maximum mtime for a source files) and set maximum mtime for the generated file like in an example that I've provided above?

PS. sorry for my bad english.

Thanks, Dmitry

jashkenas commented 14 years ago

You don't need the public/assets directory to exist, in order for Jammit to generate assets -- a plain git checkout is fine. Just make sure that the jammit command is running as the correct user for your webserver, so that you have the proper permissions for the public directory.

I'm afraid I still don't see how the mtime has anything to do with it.

dmitry commented 14 years ago

I've fixed that by creating a task for vlad the deployer: desc "Copy old assets" task :copy_old_assets do run "cp -Rf #{previous_release}/public/assets/ #{current_release}/public/" end

Then added it before the jammit invoke: Rake::Task['vlad:copy_old_assets'].invoke Rake::Task['vlad:jammit'].invoke