capistrano-plugins / capistrano-faster-assets Goto Github PK
View Code? Open in Web Editor NEWSkips asset compilation if none of the assets were changed since last release.
License: MIT License
Skips asset compilation if none of the assets were changed since last release.
License: MIT License
Since webpacker has been used widely and will be default in Rails 6, perhaps we should add app/javascript
to default assets_dependencies
.
I am willing to make PR for this.
Hi,
I've been using a custom script to precompile assets locally and just now switched to using this gem. This gem works great, but wouldn't it be faster and reduce server load to precompile the assets locally (if needed) and copy them over to server?
Here's the link to the capistrano task that I was using before:
https://github.com/TalkingQuickly/capistrano-3-rails-template/blob/master/lib/capistrano/tasks/compile_assets_locally.cap
It didn't check if compilation is required, but I think these two ideas/scripts can be merged.
Whenever I peform a deploy, I get this error and all assets are precompiled, even if no changes to Gemfile or any of the assets:
INFO[435343cb] Running /usr/bin/env ls /home/deploy/project/releases/20141127132806/assets_manifest_backup on ip
DEBUG[435343cb] Command: cd /home/deploy/project/releases/20141127132806 && ( RAILS_ENV=production /usr/bin/env ls /home/deploy/project/releases/20141127132806/assets_manifest_backup )
DEBUG[435343cb] ls: cannot access /home/deploy/project/releases/20141127132806/assets_manifest_backup
DEBUG[435343cb] : No such file or directory
INFO[8c33627a] Running ~/.rvm/bin/rvm 2.1.4@project_rails32 do bundle exec rake assets:precompile on ip
DEBUG[8c33627a] Command: cd /home/deploy/project/releases/20141127132806 && ( RAILS_ENV=production ~/.rvm/bin/rvm 2.1.4@project_rails32 do bundle exec rake assets:precompile )
I'm starting with this, but I don't really know that it's gonna help much:
find . | grep -E "(css|coffee)" | xargs -n1 grep "<%"
Thoughts?
this https://github.com/capistrano-plugins/capistrano-faster-assets/blob/master/lib/capistrano/tasks/faster_assets.rake#L45 triggers error, because capistrano/rails creates symlink to public/assets and the task creates endless loop copy
it should only compile changed assets
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Rails 4.1.1
This gem does not take into account changes to the webpacker assets and as a result the assets:precompile tasks gets incorrectly ignored.
Many improvements have been pushed to master since the last released version :) particularly this one 6b243df
Rake Task Enhance is the standard way to add prerequisites to a rake task, in one of our projects we use it to enhance the asset precompilation as in the following example:
Rake::Task['assets:precompile'].enhance ['assets:write_error_pages']
Rake::Task['assets:precompile'].enhance do
Rake::Task['assets:delete_error_pages'].invoke
end
So when clearing actions in this line (Rake::Task["deploy:assets:precompile"].clear_actions
) only the actions are cleared but not the prerequisites I believe, because the enhancements are being executed before the asset precompilation even when the clear_actions is present.
The problem is that if those enhancements create some dynamic assets, those are being created before the evaluation of the diffs in the assets folders among both releases, hence both diffs will differ
The problem in the code above is that we need to create dynamic error pages into the asset folder , then precompile them, then delete the files from the assets folder. If the diff is calculated after the files are created, the diff will find differences.
In my staging.rb environment file i was trying to precompile these files:
config.assets.precompile += ['admin/admin.css', 'admin/admin.js']
I had to remove the capistrano-faster-assets gem for this to work.
Since webpacker has been used widely and will be default in Rails 6, perhaps we should add app/javascript
to default assets_dependencies
.
I am willing to make PR for this.
Humans are smarter than machines. At least now. Sometimes the developer needs to recompile all assets no matter what. It would be nice if this gem allowed that. Via an environment variable or something like that.
Our server is using RVM, and we are using a .rvmrc (because it is still the best place to put export RAILS_ENV=staging
that I have found). This obnoxious message comes up on a newly provisioned server, and breaks the deploy:assets:backup_manifest
task.
Easy workaround: rvm rvmrc warning ignore all.rvmrcs
INFO [224cd57f] Running /usr/bin/env cp You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /web/railsapp/staging/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
/web/railsapp/staging/releases/20150610202127/public/assets/.sprockets-manifest-fd7e2ccc959215614bf6fc35b33e3f3a.json /web/railsapp/staging/releases/20150610202127/assets_manifest_backup on stage.example.com
DEBUG [224cd57f] Command: cd /web/railsapp/staging/releases/20150610202127 && /usr/bin/env cp You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /web/railsapp/staging/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
/web/railsapp/staging/releases/20150610202127/public/assets/.sprockets-manifest-fd7e2ccc959215614bf6fc35b33e3f3a.json /web/railsapp/staging/releases/20150610202127/assets_manifest_backup
DEBUG [224cd57f] You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
DEBUG [224cd57f] you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
DEBUG [224cd57f] or ignore this warning with 'rvm rvmrc warning ignore /web/railsapp/staging/.rvmrc',
DEBUG [224cd57f] '.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
DEBUG [224cd57f] to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
DEBUG [224cd57f]
DEBUG [224cd57f] cp: target ‘managers,\r’ is not a directory
DEBUG [224cd57f] bash: line 1: you: command not found
DEBUG [224cd57f] bash: line 2: or: command not found
DEBUG [224cd57f] bash: line 3: .rvmrc: command not found
DEBUG [224cd57f] bash: line 4: to: command not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Command::Failed: cp exit status: 126
cp stdout: Nothing written
cp stderr: Nothing written
Tasks: TOP => deploy:assets:backup_manifest
(See full trace by running task with --trace)
The deploy has failed with an error: cp exit status: 126
cp stdout: Nothing written
cp stderr: Nothing written
``` INFO [224cd57f] Running /usr/bin/env cp You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /web/railsapp/staging/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
/web/railsapp/staging/releases/20150610202127/public/assets/.sprockets-manifest-fd7e2ccc959215614bf6fc35b33e3f3a.json /web/railsapp/staging/releases/20150610202127/assets_manifest_backup on stage.example.com
DEBUG [224cd57f] Command: cd /web/railsapp/staging/releases/20150610202127 && /usr/bin/env cp You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /web/railsapp/staging/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
/web/railsapp/staging/releases/20150610202127/public/assets/.sprockets-manifest-fd7e2ccc959215614bf6fc35b33e3f3a.json /web/railsapp/staging/releases/20150610202127/assets_manifest_backup
DEBUG [224cd57f] You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
DEBUG [224cd57f] you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
DEBUG [224cd57f] or ignore this warning with 'rvm rvmrc warning ignore /web/railsapp/staging/.rvmrc',
DEBUG [224cd57f] '.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
DEBUG [224cd57f] to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
DEBUG [224cd57f]
DEBUG [224cd57f] cp: target ‘managers,\r’ is not a directory
DEBUG [224cd57f] bash: line 1: you: command not found
DEBUG [224cd57f] bash: line 2: or: command not found
DEBUG [224cd57f] bash: line 3: .rvmrc: command not found
DEBUG [224cd57f] bash: line 4: to: command not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Command::Failed: cp exit status: 126
cp stdout: Nothing written
cp stderr: Nothing written
Tasks: TOP => deploy:assets:backup_manifest
(See full trace by running task with --trace)
The deploy has failed with an error: cp exit status: 126
cp stdout: Nothing written
cp stderr: Nothing written
if config.action_controller.asset_host changes to another host, we should recompile assets.
If changing the version or Rails.application.config.assets.precompile It doesn't seem to run
Is there any way you can add a new branch/tag to support version 3.0.x.
This gem is a good help for people that have big deployment time, so it would be very nice to support users that don't have the luxury to update Capistrano on legacy (even if not very old) applications.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.