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

Commit e4cfc2d

Browse files
committed
Add rake task to create non-digest assets symlinks
Based on rails/sprockets-rails#49 (comment) Without this, a lot of things just don't work (including static pages).
1 parent 18328fa commit e4cfc2d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Copyright 2015, SUSE LINUX Products GmbH
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
namespace :assets do
18+
task non_digested: :environment do
19+
assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
20+
regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/
21+
assets.each do |file|
22+
next if File.directory?(file) || file !~ regex
23+
24+
source = file.split('/')
25+
source.push(source.pop.gsub(regex, '.'))
26+
27+
non_digested = File.join(source)
28+
FileUtils.symlink(file, non_digested, :force => true)
29+
end
30+
end
31+
end

0 commit comments

Comments
 (0)