Last active
October 20, 2017 18:56
-
-
Save arthurnn/9677780 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
require 'non_digest_assets' | |
namespace :assets do | |
task :non_digested do | |
NonDigestAssets.new.generate | |
end | |
end |
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
class NonDigestAssets | |
include Rake::DSL | |
FILES = ["external/app.js"] | |
def generate | |
assets_files.map do |file| | |
non_digested = file.gsub /(\-[a-z0-9]{32})/, "" | |
next unless FILES.all? {|s| non_digested =~ /#{s}/} | |
copy(file, non_digested) | |
end | |
end | |
def assets_files | |
Rake::FileList.new("public/assets/**/*") do |list| | |
list.exclude do |file| | |
file !~ /\-[a-z0-9]{32}\.[a-z]{2,4}/ | |
end | |
end | |
end | |
def copy(from, to) | |
sh "cp #{from} #{to}" | |
end | |
end |
Thanks for this. I changed FILES.all?
to FILES.any?
to support multiple files without a digest.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, iI am so sorry, but assets_files return empty array for me. (i ran precompile task before it). Thanks