sprockets-rails 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6be530b798270a9a8b0590e0faecb2189cd3c0c6b921c483c7361831885b1a5a
|
4
|
+
data.tar.gz: '09b0e1f10512e0c51797736ea6eae9c79d174b45897b54326ae22aabc8773277'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37622f84b510b136e07544cee58151e02dc2db4ab489255afbfacc8e51b2f50a6751beeaec3c96b585b249f9f654fa8357c6caca8d07337a7d1400d624f31950
|
7
|
+
data.tar.gz: 159688118eab9c77ba8820895324fbd6b13cf7c28d5626c1fb56fa3bb8dc71274f5a0422b742e3136d55a41ba2711258d881d2005d0cdeeef6fb0f766c3380c5
|
@@ -2,13 +2,15 @@ module Sprockets
|
|
2
2
|
module Rails
|
3
3
|
# Rewrites urls in CSS files with the digested paths
|
4
4
|
class AssetUrlProcessor
|
5
|
-
REGEX = /url\(\s*["']?(?!(?:\#|data|http))([^"'\s)]+)\s*["']?\)/
|
6
|
-
|
5
|
+
REGEX = /url\(\s*["']?(?!(?:\#|data|http))(?<relativeToCurrentDir>.\/)?(?<path>[^"'\s)]+)\s*["']?\)/
|
7
6
|
def self.call(input)
|
8
7
|
context = input[:environment].context_class.new(input)
|
9
|
-
data = input[:data].gsub(REGEX)
|
8
|
+
data = input[:data].gsub(REGEX) do |_match|
|
9
|
+
path = Regexp.last_match[:path]
|
10
|
+
"url(#{context.asset_path(path)})"
|
11
|
+
end
|
10
12
|
|
11
|
-
|
13
|
+
context.metadata.merge(data: data)
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -4,18 +4,50 @@ module Sprockets
|
|
4
4
|
class SourcemappingUrlProcessor
|
5
5
|
REGEX = /\/\/# sourceMappingURL=(.*\.map)/
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
class << self
|
8
|
+
def call(input)
|
9
|
+
env = input[:environment]
|
10
|
+
context = env.context_class.new(input)
|
11
|
+
data = input[:data].gsub(REGEX) do |_match|
|
12
|
+
sourcemap_logical_path = combine_sourcemap_logical_path(sourcefile: input[:name], sourcemap: $1)
|
13
|
+
|
14
|
+
begin
|
15
|
+
resolved_sourcemap_comment(sourcemap_logical_path, context: context)
|
16
|
+
rescue Sprockets::FileNotFound
|
17
|
+
removed_sourcemap_comment(sourcemap_logical_path, filename: input[:filename], env: env)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
{ data: data }
|
16
22
|
end
|
17
23
|
|
18
|
-
|
24
|
+
private
|
25
|
+
def combine_sourcemap_logical_path(sourcefile:, sourcemap:)
|
26
|
+
if (parts = sourcefile.split("/")).many?
|
27
|
+
parts[0..-2].append(sourcemap).join("/")
|
28
|
+
else
|
29
|
+
sourcemap
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def resolved_sourcemap_comment(sourcemap_logical_path, context:)
|
34
|
+
"//# sourceMappingURL=#{sourcemap_asset_path(sourcemap_logical_path, context: context)}\n//!\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
def sourcemap_asset_path(sourcemap_logical_path, context:)
|
38
|
+
# FIXME: Work-around for bug where if the sourcemap is nested two levels deep, it'll resolve as the source file
|
39
|
+
# that's being mapped, rather than the map itself. So context.resolve("a/b/c.js.map") will return "c.js?"
|
40
|
+
if context.resolve(sourcemap_logical_path) =~ /\.map/
|
41
|
+
context.asset_path(sourcemap_logical_path)
|
42
|
+
else
|
43
|
+
raise Sprockets::FileNotFound, "Failed to resolve source map asset due to nesting depth"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def removed_sourcemap_comment(sourcemap_logical_path, filename:, env:)
|
48
|
+
env.logger.warn "Removed sourceMappingURL comment for missing asset '#{sourcemap_logical_path}' from #{filename}"
|
49
|
+
nil
|
50
|
+
end
|
19
51
|
end
|
20
52
|
end
|
21
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Peek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|