propshaft 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/propshaft/compilers/css_asset_urls.rb +1 -1
- data/lib/propshaft/railtie.rb +9 -9
- data/lib/propshaft/resolver/dynamic.rb +1 -1
- data/lib/propshaft/server.rb +10 -4
- 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: b03a78a54847aa4fb74c996259230818db5262c8c246367f4826dd222f763d62
|
4
|
+
data.tar.gz: c393121a10fcb3cd1b151077869673260afdf99d4a7294dd88b8f600e3debe55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2807deda69e1f1ddb336985b69c4f2f617398450402ca60de1917599f5e6a8ad5b483386ffcd85cd62f3729ff9fb16d7a2d487e39e15de160c29342d03d4ba1
|
7
|
+
data.tar.gz: d16949bc2e7b81634d310413ea0f29065dfbe9eb4e421fb2321b9709ef460c82eaf93b2ab73d07de23dbd8111730d7755a1995081d8986d96ed28916940b8e94
|
data/README.md
CHANGED
@@ -4,10 +4,10 @@ Propshaft is an asset pipeline library for Rails. It's built for era where bundl
|
|
4
4
|
|
5
5
|
So that's what Propshaft doesn't do. Here's what it actually does provide:
|
6
6
|
|
7
|
-
1. Configurable load path
|
8
|
-
1. Digest
|
9
|
-
1. Development server
|
10
|
-
1. Basic
|
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
|
+
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
|
+
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.
|
11
11
|
|
12
12
|
|
13
13
|
## Installation
|
@@ -7,7 +7,7 @@ class Propshaft::Compilers::CssAssetUrls
|
|
7
7
|
|
8
8
|
def compile(input)
|
9
9
|
input.gsub(/asset-path\(["']([^"')]+)["']\)/) do |match|
|
10
|
-
%[url("
|
10
|
+
%[url("#{assembly.config.prefix}/#{assembly.load_path.find($1).digested_path}")]
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/propshaft/railtie.rb
CHANGED
@@ -18,15 +18,6 @@ module Propshaft
|
|
18
18
|
config.assets.prefix = "/assets"
|
19
19
|
config.assets.compilers = [ [ "text/css", Propshaft::Compilers::CssAssetUrls ] ]
|
20
20
|
|
21
|
-
# Compatibility shiming (need to provide log warnings when used)
|
22
|
-
config.assets.precompile = []
|
23
|
-
config.assets.debug = nil
|
24
|
-
config.assets.quiet = nil
|
25
|
-
config.assets.compile = nil
|
26
|
-
config.assets.version = nil
|
27
|
-
config.assets.css_compressor = nil
|
28
|
-
config.assets.js_compressor = nil
|
29
|
-
|
30
21
|
config.after_initialize do |app|
|
31
22
|
config.assets.output_path ||=
|
32
23
|
Pathname.new(File.join(app.config.paths["public"].first, app.config.assets.prefix))
|
@@ -50,5 +41,14 @@ module Propshaft
|
|
50
41
|
end
|
51
42
|
end
|
52
43
|
end
|
44
|
+
|
45
|
+
# Compatibility shiming (need to provide log warnings when used)
|
46
|
+
config.assets.precompile = []
|
47
|
+
config.assets.debug = nil
|
48
|
+
config.assets.quiet = nil
|
49
|
+
config.assets.compile = nil
|
50
|
+
config.assets.version = nil
|
51
|
+
config.assets.css_compressor = nil
|
52
|
+
config.assets.js_compressor = nil
|
53
53
|
end
|
54
54
|
end
|
data/lib/propshaft/server.rb
CHANGED
@@ -6,7 +6,9 @@ class Propshaft::Server
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(env)
|
9
|
-
|
9
|
+
path, digest = extract_path_and_digest(env)
|
10
|
+
|
11
|
+
if (asset = @assembly.load_path.find(path)) && asset.digest == digest
|
10
12
|
compiled_content = @assembly.compilers.compile(asset)
|
11
13
|
|
12
14
|
[
|
@@ -15,7 +17,7 @@ class Propshaft::Server
|
|
15
17
|
"Content-Length" => compiled_content.length.to_s,
|
16
18
|
"Content-Type" => asset.content_type,
|
17
19
|
"ETag" => asset.digest,
|
18
|
-
"Cache-Control" => "public,
|
20
|
+
"Cache-Control" => "public, max-age=31536000, immutable"
|
19
21
|
},
|
20
22
|
[ compiled_content ]
|
21
23
|
]
|
@@ -25,7 +27,11 @@ class Propshaft::Server
|
|
25
27
|
end
|
26
28
|
|
27
29
|
private
|
28
|
-
def
|
29
|
-
Rack::Utils.unescape(env["PATH_INFO"].to_s.sub(/^\//, ""))
|
30
|
+
def extract_path_and_digest(env)
|
31
|
+
full_path = Rack::Utils.unescape(env["PATH_INFO"].to_s.sub(/^\//, ""))
|
32
|
+
digest = full_path[/-([0-9a-f]{7,128})\.[^.]+\z/, 1]
|
33
|
+
path = digest ? full_path.sub("-#{digest}", "") : full_path
|
34
|
+
|
35
|
+
[ path, digest ]
|
30
36
|
end
|
31
37
|
end
|
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.1.
|
4
|
+
version: 0.1.1
|
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-09-
|
11
|
+
date: 2021-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|