propshaft 0.6.0 → 0.6.4
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 +4 -4
- data/README.md +2 -4
- data/lib/propshaft/compilers/css_asset_urls.rb +1 -1
- data/lib/propshaft/load_path.rb +10 -1
- data/lib/propshaft/resolver/dynamic.rb +6 -0
- data/lib/propshaft/resolver/static.rb +6 -0
- data/lib/propshaft/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bee1e0c2fcf39062df053618528b93dd5977bd8968fea03a67d31b7196f04f9
|
4
|
+
data.tar.gz: ad9c5f3b7bc878a359931d2c1edc2a2ecb98004b8cfba38dd226acd0a19e43ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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)]+)
|
6
|
+
ASSET_URL_PATTERN = /url\(\s*["']?(?!(?:\#|data|http))([^"'\s?#)]+)([#?][^"']+)?\s*["']?\)/
|
7
7
|
|
8
8
|
def initialize(assembly)
|
9
9
|
@assembly = assembly
|
data/lib/propshaft/load_path.rb
CHANGED
@@ -4,7 +4,7 @@ class Propshaft::LoadPath
|
|
4
4
|
attr_reader :paths, :version
|
5
5
|
|
6
6
|
def initialize(paths = [], version: nil)
|
7
|
-
@paths =
|
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
|
@@ -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)
|
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.6.
|
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-
|
11
|
+
date: 2022-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|