Skip to content

Instantly share code, notes, and snippets.

View iantheparker's full-sized avatar

Ian Parker iantheparker

View GitHub Profile
@iantheparker
iantheparker / yarn_resolve_assets.rake
Last active April 10, 2018 15:23
Resolve Yarn assets for Cloudfront in Sprockets/Rails
desc "resolve_asset paths installed via Yarn"
task :resolve_assets => :environment do
components_directory = 'node_modules'
root_directory = components_directory
# Resolve relative paths in CSS
Dir["#{components_directory}/**/*.css"].each do |filename|
contents = File.read(filename) if FileTest.file?(filename)
# http://www.w3.org/TR/CSS2/syndata.html#uri
url_regex = /url\((?!\#)\s*['"]?((?![a-z]+:)([^'"\)]*?)([?#][^'"\)]*)?)['"]?\s*\)/

Keybase proof

I hereby claim:

  • I am iantheparker on github.
  • I am iantheparker (https://keybase.io/iantheparker) on keybase.
  • I have a public key ASBa9MDrV6XQEwPJ_pgwaQTdNj81c6xHsLEv2rfI8zGGwwo

To claim this, I am signing this object: