sprockets-rails 3.4.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/sprockets/rails/asset_url_processor.rb +2 -2
- data/lib/sprockets/rails/helper.rb +1 -2
- data/lib/sprockets/rails/quiet_assets.rb +14 -0
- data/lib/sprockets/rails/route_wrapper.rb +0 -10
- data/lib/sprockets/rails/version.rb +1 -1
- data/lib/sprockets/rails.rb +9 -0
- data/lib/sprockets/railtie.rb +21 -23
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a51f06b8c5ad01f10611895d361f493f20793676b3a04182f5bea67b2f5a3109
|
4
|
+
data.tar.gz: 0ad6746d0b030fb467c6f24c343d2b6eb2b372a89f0cf232b3b97825ab103a2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 534796ce9f7e854c034119104a45c2112f3a72f606c6af5eb73b7d3bcdf76c00c91e65f632775b22320ac39c218a369c950da583269ec7023012b8a2f89e3181
|
7
|
+
data.tar.gz: bb0a83b01f58aa870429fa8be470343ee13e8c18aeb50312202724cc773eb52531ec74baa7b4a023a4a73c62897fbdc2de448db3aaf39fc58f65ffc5771d4a2a
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Sprockets Rails
|
2
2
|
|
3
|
-
Provides Sprockets implementation for Rails 4.x (and beyond) Asset Pipeline.
|
3
|
+
Provides [Sprockets](https://github.com/rails/sprockets) implementation for Rails 4.x (and beyond) Asset Pipeline.
|
4
4
|
|
5
5
|
|
6
6
|
## Installation
|
@@ -86,7 +86,7 @@ When enabled, fingerprints will be added to asset filenames.
|
|
86
86
|
|
87
87
|
**`config.assets.debug`**
|
88
88
|
|
89
|
-
Enable
|
89
|
+
Enable asset debugging mode. A source map will be included with each asset when this is true.
|
90
90
|
|
91
91
|
**`config.assets.compile`**
|
92
92
|
|
@@ -108,6 +108,10 @@ config.assets.configure do |env|
|
|
108
108
|
end
|
109
109
|
```
|
110
110
|
|
111
|
+
**`config.assets.resolve_assets_in_css_urls`**
|
112
|
+
|
113
|
+
When this option is enabled, sprockets-rails will register a CSS postprocessor to resolve assets referenced in [`url()`](https://developer.mozilla.org/en-US/docs/Web/CSS/url()) function calls and replace them with the digested paths. Defaults to `true`.
|
114
|
+
|
111
115
|
**`config.assets.resolve_with`**
|
112
116
|
|
113
117
|
A list of `:environment` and `:manifest` symbols that defines the order that
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Sprockets
|
2
2
|
module Rails
|
3
|
-
#
|
3
|
+
# Resolve assets referenced in CSS `url()` calls and replace them with the digested paths
|
4
4
|
class AssetUrlProcessor
|
5
|
-
REGEX = /url\(\s*["']?(?!(?:\#|data|http))(?<relativeToCurrentDir
|
5
|
+
REGEX = /url\(\s*["']?(?!(?:\#|data|http))(?<relativeToCurrentDir>\.\/)?(?<path>[^"'\s)]+)\s*["']?\)/
|
6
6
|
def self.call(input)
|
7
7
|
context = input[:environment].context_class.new(input)
|
8
8
|
data = input[:data].gsub(REGEX) do |_match|
|
@@ -89,8 +89,7 @@ module Sprockets
|
|
89
89
|
message << "To bypass the asset pipeline and preserve this behavior,\n"
|
90
90
|
message << "use the `skip_pipeline: true` option.\n"
|
91
91
|
|
92
|
-
|
93
|
-
ActiveSupport::Deprecation.warn(message, call_stack)
|
92
|
+
Sprockets::Rails.deprecator.warn(message, caller_locations)
|
94
93
|
end
|
95
94
|
super
|
96
95
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Sprockets
|
2
2
|
module Rails
|
3
|
+
class LoggerSilenceError < StandardError; end
|
4
|
+
|
3
5
|
class QuietAssets
|
4
6
|
def initialize(app)
|
5
7
|
@app = app
|
@@ -8,11 +10,23 @@ module Sprockets
|
|
8
10
|
|
9
11
|
def call(env)
|
10
12
|
if env['PATH_INFO'] =~ @assets_regex
|
13
|
+
raise_logger_silence_error unless ::Rails.logger.respond_to?(:silence)
|
14
|
+
|
11
15
|
::Rails.logger.silence { @app.call(env) }
|
12
16
|
else
|
13
17
|
@app.call(env)
|
14
18
|
end
|
15
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def raise_logger_silence_error
|
23
|
+
error = "You have enabled `config.assets.quiet`, but your `Rails.logger`\n"
|
24
|
+
error << "does not use the `LoggerSilence` module.\n\n"
|
25
|
+
error << "Please use a compatible logger such as `ActiveSupport::Logger`\n"
|
26
|
+
error << "to take advantage of quiet asset logging.\n\n"
|
27
|
+
|
28
|
+
raise LoggerSilenceError, error
|
29
|
+
end
|
16
30
|
end
|
17
31
|
end
|
18
32
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Sprockets
|
2
2
|
module Rails
|
3
3
|
module RouteWrapper
|
4
|
-
|
5
4
|
def internal_assets_path?
|
6
5
|
path =~ %r{\A#{self.class.assets_prefix}\z}
|
7
6
|
end
|
@@ -9,15 +8,6 @@ module Sprockets
|
|
9
8
|
def internal?
|
10
9
|
super || internal_assets_path?
|
11
10
|
end
|
12
|
-
|
13
|
-
def self.included(klass)
|
14
|
-
klass.class_eval do
|
15
|
-
def internal_with_sprockets?
|
16
|
-
internal_without_sprockets? || internal_assets_path?
|
17
|
-
end
|
18
|
-
alias_method_chain :internal?, :sprockets
|
19
|
-
end
|
20
|
-
end
|
21
11
|
end
|
22
12
|
end
|
23
13
|
end
|
data/lib/sprockets/rails.rb
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
require 'sprockets/rails/version'
|
2
|
+
require 'active_support'
|
2
3
|
if defined? Rails::Railtie
|
3
4
|
require 'sprockets/railtie'
|
4
5
|
end
|
6
|
+
|
7
|
+
module Sprockets
|
8
|
+
module Rails
|
9
|
+
def self.deprecator
|
10
|
+
@deprecator ||= ActiveSupport::Deprecation.new("4.0", "Sprockets::Rails")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/sprockets/railtie.rb
CHANGED
@@ -53,17 +53,6 @@ module Rails
|
|
53
53
|
@precompiled_assets ||= assets_manifest.find(config.assets.precompile).map(&:logical_path).to_set
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
57
|
-
class Engine < Railtie
|
58
|
-
# Skip defining append_assets_path on Rails <= 4.2
|
59
|
-
unless initializers.find { |init| init.name == :append_assets_path }
|
60
|
-
initializer :append_assets_path, :group => :all do |app|
|
61
|
-
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
|
62
|
-
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
|
63
|
-
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
56
|
end
|
68
57
|
|
69
58
|
module Sprockets
|
@@ -96,13 +85,20 @@ module Sprockets
|
|
96
85
|
end
|
97
86
|
end
|
98
87
|
|
88
|
+
::Rails::Engine.initializer :append_assets_path, :group => :all do |app|
|
89
|
+
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
|
90
|
+
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
|
91
|
+
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
|
92
|
+
end
|
93
|
+
|
99
94
|
config.assets = OrderedOptions.new
|
100
|
-
config.assets._blocks
|
101
|
-
config.assets.paths
|
102
|
-
config.assets.precompile
|
103
|
-
config.assets.prefix
|
104
|
-
config.assets.manifest
|
105
|
-
config.assets.quiet
|
95
|
+
config.assets._blocks = []
|
96
|
+
config.assets.paths = []
|
97
|
+
config.assets.precompile = []
|
98
|
+
config.assets.prefix = "/assets"
|
99
|
+
config.assets.manifest = nil
|
100
|
+
config.assets.quiet = false
|
101
|
+
config.assets.resolve_assets_in_css_urls = true
|
106
102
|
|
107
103
|
initializer :set_default_precompile do |app|
|
108
104
|
if using_sprockets4?
|
@@ -120,13 +116,19 @@ module Sprockets
|
|
120
116
|
end
|
121
117
|
|
122
118
|
initializer :asset_url_processor do |app|
|
123
|
-
|
119
|
+
if app.config.assets.resolve_assets_in_css_urls
|
120
|
+
Sprockets.register_postprocessor "text/css", ::Sprockets::Rails::AssetUrlProcessor
|
121
|
+
end
|
124
122
|
end
|
125
123
|
|
126
124
|
initializer :asset_sourcemap_url_processor do |app|
|
127
125
|
Sprockets.register_postprocessor "application/javascript", ::Sprockets::Rails::SourcemappingUrlProcessor
|
128
126
|
end
|
129
127
|
|
128
|
+
initializer "sprockets-rails.deprecator" do |app|
|
129
|
+
app.deprecators[:sprockets_rails] = Sprockets::Rails.deprecator if app.respond_to?(:deprecators)
|
130
|
+
end
|
131
|
+
|
130
132
|
config.assets.version = ""
|
131
133
|
config.assets.debug = false
|
132
134
|
config.assets.compile = true
|
@@ -234,11 +236,7 @@ module Sprockets
|
|
234
236
|
ActionDispatch::Routing::RouteWrapper.class_eval do
|
235
237
|
class_attribute :assets_prefix
|
236
238
|
|
237
|
-
|
238
|
-
prepend Sprockets::Rails::RouteWrapper
|
239
|
-
else
|
240
|
-
include Sprockets::Rails::RouteWrapper
|
241
|
-
end
|
239
|
+
prepend Sprockets::Rails::RouteWrapper
|
242
240
|
|
243
241
|
self.assets_prefix = config.assets.prefix
|
244
242
|
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
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Peek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|
@@ -30,42 +30,42 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '6.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '6.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '6.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '6.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: railties
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '6.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '6.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
|
-
rubygems_version: 3.
|
149
|
+
rubygems_version: 3.5.9
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Sprockets Rails integration
|