Created
October 28, 2019 21:33
-
-
Save danmayer/96ec7c37d1a775e021deea88fd804429 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: We monkey patch because the unknown_asset_fallback option | |
# doesn't seem to do what we expect, when compile scss see more below | |
# | |
# Rails.application.config.assets.unknown_asset_fallback = false | |
# ^^ The above works for image_tag("head_liner.svg") references, but fails for scss | |
# | |
# This patch ensures we also fail on scss | |
# patched against: sprockets (3.7.2), sprockets-rails (3.2.1), sass-rails (5.1.0) | |
# I suspect it is slightly different and perhaps the config works as expected in differnt versions | |
# of sprockets, sprockets-rails, sass-rails | |
# | |
# patching: | |
# https://github.com/rails/sprockets-rails/blob/49bf8022c8d3e1d7348b3fe2e0931b2e448f1f58/lib/sprockets/rails/context.rb#L21 | |
### | |
module Sprockets | |
module Rails | |
module Context | |
def compute_asset_path(path, options = {}) | |
@dependencies << 'actioncontroller-asset-url-config' | |
begin | |
asset_uri = resolve(path) | |
rescue FileNotFound | |
# TODO: eh, we should be able to use a form of locate that returns | |
# nil instead of raising an exception. | |
raise Sprockets::Rails::Helper::AssetNotFound.new("path not resolved: #{path}") | |
end | |
if asset_uri | |
asset = link_asset(path) | |
digest_path = asset.digest_path | |
path = digest_path if digest_assets | |
File.join(assets_prefix || "/", path) | |
else | |
super | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment