Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit c7babb6

Browse files
committed
Generate the asset hash for a file based on its built contents, not the static contents from sprockets.
1 parent 2f79626 commit c7babb6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/tasks/requirejs-rails_tasks.rake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ OS X Homebrew users can use 'brew install node'.
160160
asset = requirejs.env.find_asset(asset_name)
161161

162162
built_asset_path = requirejs.config.build_dir.join(asset_name)
163-
digest_name = asset.digest_path
163+
164+
file_digest = ::Rails.application.assets.file_digest(built_asset_path)
165+
hex_digest = Sprockets::DigestUtils.pack_hexdigest(file_digest)
166+
digest_name = asset.logical_path.sub(/\.(\w+)$/) { |ext| "-#{hex_digest}#{ext}" }
167+
164168
digest_asset_path = requirejs.config.target_dir + digest_name
165169

166170
# Ensure that the parent directory `a/b` for modules with names like `a/b/c` exist.

0 commit comments

Comments
 (0)