Skip to content

Instantly share code, notes, and snippets.

@yalab
Created April 7, 2018 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yalab/bb4fe1d2466f08d30b38523e17878198 to your computer and use it in GitHub Desktop.
Save yalab/bb4fe1d2466f08d30b38523e17878198 to your computer and use it in GitHub Desktop.
User definition sprockets function
module Sprockets::SassProcessor::Functions
def cdn_path(path, options={})
prefix = if (asset_host = Rails.application.config.action_controller.asset_host)
asset_host.scan(%r(/[^/]+\Z)).first
else
""
end
prefixed = prefix + asset_path(path, options).to_s
Sass::Script::String.new(prefixed)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment