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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b51bb39ebb02eaa2eb0491eb6af28b1d6034d8b6dbed1da92161cc9d6ece2a7
4
- data.tar.gz: 80426c2f10fe259bb7aec42c86f15581686680a4bb017117c677df2cc95150e1
3
+ metadata.gz: bf7a6dfbec5ee900ab10a5529d4551966a651faa5ce230583835905d081a16a8
4
+ data.tar.gz: f02416e16d969bfa93ac9a35896f2b0bbfdc613a01e4d3636822ff0d94ebdbc5
5
5
  SHA512:
6
- metadata.gz: 35ca25b6bc30528fa870343793320c59265819b1154ac14d0f2fefa4288a66c686e63b87ddc264d3ab3a467df1be0399b8bb37a0e3d157f5c5240eb6756db7d8
7
- data.tar.gz: 9d3abd851135146a1bacf62c73c755679d4bc76f920b89f969a4f4b34700c09a3334025a15531f85196a420a63c2d5f77f7f7bacdff91ab4c8537117982c0948
6
+ metadata.gz: 3fd44fff6ed74eeba5dc3817d7fbfa32176f04b10aa5e96d260253429a70960c685fdff036bebfdcd628ba29227437b5ea6dd6ae0f25b92ef37254844ab9527b
7
+ data.tar.gz: 4f97be12d0adc4255ec615201b2d92c55aed0e6c6d846da2cb9cca9fd993a921ad3c2a7a1f37430bd1cb724957541737c2f177d94b236f122a7458b994f57ad6
@@ -5,6 +5,7 @@ require "propshaft/server"
5
5
  require "propshaft/processor"
6
6
  require "propshaft/compilers"
7
7
  require "propshaft/compilers/css_asset_urls"
8
+ require "propshaft/compilers/source_mapping_urls"
8
9
 
9
10
  class Propshaft::Assembly
10
11
  attr_reader :config
@@ -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
@@ -16,7 +16,7 @@ class Propshaft::Processor
16
16
  compress_assets
17
17
  end
18
18
 
19
- def clean
19
+ def clobber
20
20
  FileUtils.rm_r(output_path) if File.exist?(output_path)
21
21
  end
22
22
 
@@ -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 = [ [ "text/css", Propshaft::Compilers::CssAssetUrls ] ]
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 clean: :environment do
59
+ task clobber: :environment do
56
60
  Rails.application.assets.processor.clean
57
61
  end
58
62
 
@@ -1,3 +1,3 @@
1
1
  module Propshaft
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.2
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 00:00:00.000000000 Z
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