propshaft 0.6.0 → 0.6.4

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: f7f4103bd65db2fdda3e1e8817f9d14951c48c2e823794c6167b90363931f48d
4
- data.tar.gz: dd2503eb87c35fbf647618c2d840f05705583dfabcaac41ae68624923d92736f
3
+ metadata.gz: 7bee1e0c2fcf39062df053618528b93dd5977bd8968fea03a67d31b7196f04f9
4
+ data.tar.gz: ad9c5f3b7bc878a359931d2c1edc2a2ecb98004b8cfba38dd226acd0a19e43ff
5
5
  SHA512:
6
- metadata.gz: 5d0a9695812b4fa23ada2001d8f6f8adcc6d4cd8d724fe433fc08aeef48262e3b24e9de5a48ebde7b1d2aafee0ee5d58216ed9b252bdd7ba9fc10b0e87334250
7
- data.tar.gz: 905a4681b68df4fa2020fc7a17e7b3fb50e6b67b9b332a903cbf2752aca3c6d83e03c5d198fa680e06299d1743a1ec0787e88f4f43ca2498dd94e46e73d09b63
6
+ metadata.gz: 41a54360ed2d9424f1c190af2606c5d2bc88a2d01d61a1396ed60fc64ba1531e815cc259ac41904fe3a49053d057ee2f838be0c8763b37a1ebbe79067f52301f
7
+ data.tar.gz: be6381394ff2c2dfa9bf0ca23d2023b196492d83012970091eca5ce03822ee127fa40103382dd85d6093ae1edc5b91545a59be21beb0a9736fa3037a322d5678
data/README.md CHANGED
@@ -7,7 +7,7 @@ So that's what Propshaft doesn't do. Here's what it does provide:
7
7
  1. **Configurable load path**: You can register directories from multiple places in your app and gems, and reference assets from all of these paths as though they were one.
8
8
  1. **Digest stamping**: All assets in the load path will be copied (or compiled) in a precompilation step for production that also stamps all of them with a digest hash, so you can use long-expiry cache headers for better performance. The digested assets can be referred to through their logical path because the processing leaves a manifest file that provides a way to translate.
9
9
  1. **Development server**: There's no need to precompile the assets in development. You can refer to them via the same asset_path helpers and they'll be served by a development server.
10
- 1. **Basic compilers**: Propshaft was explicitly not designed to provide full transpiler capabilities. You can get that better elsewhere. But it does offer a simple input->output compiler setup that by default is used to translate `asset-path` function calls in CSS to `url(digested-asset)` instead.
10
+ 1. **Basic compilers**: Propshaft was explicitly not designed to provide full transpiler capabilities. You can get that better elsewhere. But it does offer a simple input->output compiler setup that by default is used to translate `url(asset)` function calls in CSS to `url(digested-asset)` instead and source mapping comments likewise.
11
11
 
12
12
 
13
13
  ## Installation
@@ -18,12 +18,10 @@ With Rails 7+, you can start a new application with propshaft using `rails new m
18
18
 
19
19
  Propshaft makes all the assets from all the paths it's been configured with through `config.assets.paths` available for serving and will copy all of them into `public/assets` when precompiling. This is unlike Sprockets, which did not copy over assets that hadn't been explicitly included in one of the bundled assets.
20
20
 
21
- You can however exempt directories that have been added through the `config.assets.excluded_paths`. This is useful if you're for example using `app/assets/stylesheets` exclusively as a set of inputs to a compiler like Dart Sass for Rails, and you don't want these input files to be part of the load path.
21
+ You can however exempt directories that have been added through the `config.assets.excluded_paths`. This is useful if you're for example using `app/assets/stylesheets` exclusively as a set of inputs to a compiler like Dart Sass for Rails, and you don't want these input files to be part of the load path. (Remember you need to add full paths, like `Rails.root.join("app/assets/stylesheets")`).
22
22
 
23
23
  These assets can be referenced through their logical path using the normal helpers like `asset_path`, `image_tag`, `javascript_include_tag`, and all the other asset helper tags. These logical references are automatically converted into digest-aware paths in production when `assets:precompile` has been run (through a JSON mapping file found in `public/assets/.manifest.json`).
24
24
 
25
- Additionally, Propshaft ships with a CSS function called `asset-path("image.svg")` that'll be compiled into `url("/assets/image-f2e1ec14d6856e1958083094170ca6119c529a73.svg")` when doing `assets:precompile`. This function is applied to all `.css` files.
26
-
27
25
 
28
26
  ## Bypassing the digest step
29
27
 
@@ -3,7 +3,7 @@
3
3
  class Propshaft::Compilers::CssAssetUrls
4
4
  attr_reader :assembly
5
5
 
6
- ASSET_URL_PATTERN = /url\(\s*["']?(?!(?:\#|data|http))([^"'\s)]+)\s*["']?\)/
6
+ ASSET_URL_PATTERN = /url\(\s*["']?(?!(?:\#|data|http))([^"'\s?#)]+)([#?][^"']+)?\s*["']?\)/
7
7
 
8
8
  def initialize(assembly)
9
9
  @assembly = assembly
@@ -4,7 +4,7 @@ class Propshaft::LoadPath
4
4
  attr_reader :paths, :version
5
5
 
6
6
  def initialize(paths = [], version: nil)
7
- @paths = Array(paths).collect { |path| Pathname.new(path) }
7
+ @paths = dedup(paths)
8
8
  @version = version
9
9
  end
10
10
 
@@ -65,4 +65,13 @@ class Propshaft::LoadPath
65
65
  def clear_cache
66
66
  @cached_assets_by_path = nil
67
67
  end
68
+
69
+ def dedup(paths)
70
+ paths = Array(paths).map { |path| Pathname.new(path) }
71
+ deduped = [].tap do |deduped|
72
+ paths.sort.each { |path| deduped << path if deduped.blank? || !path.to_s.start_with?(deduped.last.to_s) }
73
+ end
74
+
75
+ paths & deduped
76
+ end
68
77
  end
@@ -11,5 +11,11 @@ module Propshaft::Resolver
11
11
  File.join prefix, asset.digested_path
12
12
  end
13
13
  end
14
+
15
+ def read(logical_path)
16
+ if asset = load_path.find(logical_path)
17
+ asset.content
18
+ end
19
+ end
14
20
  end
15
21
  end
@@ -12,6 +12,12 @@ module Propshaft::Resolver
12
12
  end
13
13
  end
14
14
 
15
+ def read(logical_path)
16
+ if asset_path = parsed_manifest[logical_path]
17
+ manifest_path.dirname.join(asset_path).read
18
+ end
19
+ end
20
+
15
21
  private
16
22
  def parsed_manifest
17
23
  @parsed_manifest ||= JSON.parse(manifest_path.read)
@@ -1,3 +1,3 @@
1
1
  module Propshaft
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.4"
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.6.0
4
+ version: 0.6.4
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: 2022-02-10 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack