Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed assets symlinking for Heroku #446

Merged
merged 1 commit into from
Jun 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
All notable changes to this project will be documented in this file. Items under `Unreleased` is upcoming features that will be out in next version.

Contributors: please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.

## [Unreleased]

## [6.0.3]
##### Fixed
- Added assets symlinking support on Heroku [#446](https://github.com/shakacode/react_on_rails/pull/446) by [Alexey Karasev](https://github.com/alleycat-at-git).

## [6.0.2]
##### Fixed
- Fix colisions in ids of DOM nodes generated by `react_component` by indexing in using an UUID rather than an auto-increment value. This means that it should be overriden using the `id` parameter of `react_component` if one wants to generate a predictable id (_e.g._ for testing purpose). See [Issue #437](https://github.com/shakacode/react_on_rails/issues/437). Fixed in [#438](https://github.com/shakacode/react_on_rails/pull/438) by [Michael Baudino](https://github.com/michaelbaudino).
Expand Down Expand Up @@ -340,7 +345,8 @@ Best done with Object destructing:
##### Fixed
- Fix several generator related issues.

[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.0.2...master
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.0.3...master
[6.0.3]: https://github.com/shakacode/react_on_rails/compare/6.0.2...6.0.3
[6.0.2]: https://github.com/shakacode/react_on_rails/compare/6.0.1...6.0.2
[6.0.1]: https://github.com/shakacode/react_on_rails/compare/6.0.0...6.0.1
[6.0.0]: https://github.com/shakacode/react_on_rails/compare/5.2.0...6.0.0
Expand Down
31 changes: 11 additions & 20 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ module ReactOnRails
end

def symlink_file(target, symlink)
if not File.exist?(symlink) or File.lstat(symlink).symlink?
if File.exist?(target)
puts "React On Rails: Symlinking #{target} to #{symlink}"
FileUtils.ln_s target, symlink, force: true
target_path = ReactOnRails::assets_path.join(target)
symlink_path = ReactOnRails::assets_path.join(symlink)
if not File.exist?(symlink_path) or File.lstat(symlink_path).symlink?
if File.exist?(target_path)
puts "React On Rails: Symlinking #{target_path} to #{symlink_path}"
`cd #{ReactOnRails::assets_path} && ln -s #{target} #{symlink}`
end
else
puts "React On Rails: File #{symlink} already exists. Failed to symlink #{target}"
puts "React On Rails: File #{symlink_path} already exists. Failed to symlink #{target_path}"
end
end
end
Expand All @@ -37,13 +39,10 @@ namespace :react_on_rails do
manifest_data["assets"].each do |logical_path, digested_path|
regex = ReactOnRails.configuration.symlink_non_digested_assets_regex
if logical_path =~ regex
full_digested_path = ReactOnRails::assets_path.join(digested_path)
full_nondigested_path = ReactOnRails::assets_path.join(logical_path)
extension = full_digested_path.extname
full_digested_gz_path = full_digested_path.sub_ext("#{extension}.gz")
full_nondigested_gz_path = full_nondigested_path.sub_ext("#{extension}.gz")
ReactOnRails::symlink_file(full_digested_path, full_nondigested_path)
ReactOnRails::symlink_file(full_digested_gz_path, full_nondigested_gz_path)
digested_gz_path = "#{digested_path}.gz"
logical_gz_path = "#{logical_path}.gz"
ReactOnRails::symlink_file(digested_path, logical_path)
ReactOnRails::symlink_file(digested_gz_path, logical_gz_path)
end
end
end
Expand Down Expand Up @@ -115,11 +114,3 @@ Rake::Task["assets:precompile"]
Rake::Task["react_on_rails:assets:delete_broken_symlinks"].invoke
end

# puts "Enhancing assets:precompile with react_on_rails:assets:compile_environment"
# Rake::Task["assets:precompile"]
# .clear_prerequisites
# .enhance([:environment]) do
# Rake::Task["react_on_rails:assets:compile_environment"].invoke
# Rake::Task["react_on_rails:assets:symlink_non_digested_assets"].invoke
# Rake::Task["react_on_rails:assets:delete_broken_symlinks"].invoke
# end