Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Commit

Permalink
Add rake task to create non-digest assets symlinks
Browse files Browse the repository at this point in the history
Based on
rails/sprockets-rails#49 (comment)

Without this, a lot of things just don't work (including static pages).
  • Loading branch information
vuntz committed Feb 2, 2015
1 parent 18328fa commit e4cfc2d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions crowbar_framework/lib/tasks/assets.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright 2015, SUSE LINUX Products GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

namespace :assets do
task non_digested: :environment do
assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/
assets.each do |file|
next if File.directory?(file) || file !~ regex

source = file.split('/')
source.push(source.pop.gsub(regex, '.'))

non_digested = File.join(source)
FileUtils.symlink(file, non_digested, :force => true)
end
end
end

1 comment on commit e4cfc2d

@brodjustice
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice solution to the Rail 4/5 non-digested-assets problem which still exists 3 years on. The only hiccup I see though is that eventually as the assets are updated the symbolically linked version eventually be deleted. Have you developed a strategy for this?

Please sign in to comment.