propshaft 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/propshaft/assembly.rb +1 -0
- data/lib/propshaft/compilers/source_mapping_urls.rb +33 -0
- data/lib/propshaft/processor.rb +1 -1
- data/lib/propshaft/railtie.rb +6 -2
- data/lib/propshaft/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf7a6dfbec5ee900ab10a5529d4551966a651faa5ce230583835905d081a16a8
|
4
|
+
data.tar.gz: f02416e16d969bfa93ac9a35896f2b0bbfdc613a01e4d3636822ff0d94ebdbc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fd44fff6ed74eeba5dc3817d7fbfa32176f04b10aa5e96d260253429a70960c685fdff036bebfdcd628ba29227437b5ea6dd6ae0f25b92ef37254844ab9527b
|
7
|
+
data.tar.gz: 4f97be12d0adc4255ec615201b2d92c55aed0e6c6d846da2cb9cca9fd993a921ad3c2a7a1f37430bd1cb724957541737c2f177d94b236f122a7458b994f57ad6
|
data/lib/propshaft/assembly.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Propshaft::Compilers::SourceMappingUrls
|
4
|
+
attr_reader :assembly
|
5
|
+
|
6
|
+
SOURCE_MAPPING_PATTERN = /\/\/# sourceMappingURL=(.*\.map)/
|
7
|
+
|
8
|
+
def initialize(assembly)
|
9
|
+
@assembly = assembly
|
10
|
+
end
|
11
|
+
|
12
|
+
def compile(logical_path, input)
|
13
|
+
input.gsub(SOURCE_MAPPING_PATTERN) { source_mapping_url(asset_path($1, logical_path)) }
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def asset_path(source_mapping_url, logical_path)
|
18
|
+
if logical_path.dirname.to_s == "."
|
19
|
+
source_mapping_url
|
20
|
+
else
|
21
|
+
logical_path.dirname.join(source_mapping_url).to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def source_mapping_url(resolved_path)
|
26
|
+
if asset = assembly.load_path.find(resolved_path)
|
27
|
+
"//# sourceMappingURL=#{assembly.config.prefix}/#{asset.digested_path}"
|
28
|
+
else
|
29
|
+
Propshaft.logger.warn "Removed sourceMappingURL comment for missing asset '#{resolved_path}' from #{resolved_path}"
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/propshaft/processor.rb
CHANGED
data/lib/propshaft/railtie.rb
CHANGED
@@ -16,7 +16,11 @@ module Propshaft
|
|
16
16
|
config.assets = ActiveSupport::OrderedOptions.new
|
17
17
|
config.assets.paths = []
|
18
18
|
config.assets.prefix = "/assets"
|
19
|
-
config.assets.compilers = [
|
19
|
+
config.assets.compilers = [
|
20
|
+
[ "text/css", Propshaft::Compilers::CssAssetUrls ],
|
21
|
+
[ "text/css", Propshaft::Compilers::SourceMappingUrls ],
|
22
|
+
[ "text/javascript", Propshaft::Compilers::SourceMappingUrls ]
|
23
|
+
]
|
20
24
|
config.assets.sweep_cache = Rails.env.development?
|
21
25
|
|
22
26
|
config.after_initialize do |app|
|
@@ -52,7 +56,7 @@ module Propshaft
|
|
52
56
|
end
|
53
57
|
|
54
58
|
desc "Remove config.assets.output_path"
|
55
|
-
task
|
59
|
+
task clobber: :environment do
|
56
60
|
Rails.application.assets.processor.clean
|
57
61
|
end
|
58
62
|
|
data/lib/propshaft/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: propshaft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
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: rails
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/propshaft/asset.rb
|
39
39
|
- lib/propshaft/compilers.rb
|
40
40
|
- lib/propshaft/compilers/css_asset_urls.rb
|
41
|
+
- lib/propshaft/compilers/source_mapping_urls.rb
|
41
42
|
- lib/propshaft/errors.rb
|
42
43
|
- lib/propshaft/helper.rb
|
43
44
|
- lib/propshaft/load_path.rb
|