propshaft 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/propshaft/assembly.rb +4 -2
- data/lib/propshaft/asset.rb +1 -1
- data/lib/propshaft/railtie.rb +14 -12
- data/lib/propshaft/railties/assets.rake +8 -1
- data/lib/propshaft/server.rb +1 -1
- data/lib/propshaft/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed27e836fd19bb9d9293ca1fad143a3aa6454c40e671891cd47cfd279524d16f
|
4
|
+
data.tar.gz: fa7b4f0f3dd48634b0d9f5ba012bc1d90d43445aee137846c6a9e66c96754e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daea545ac84a7c13ddb0198544f3058fbde3ccf9dfa42302f705613f4ec06c8c9962e2ffebe8276a9cc97912122ee8b8591c246f0ff09d6a91124c49b142bd09
|
7
|
+
data.tar.gz: '09355d57890f7b5ac3372f9d76dd08784f2e2b1de7b83f099ef8c9f3eebd73d53a2247e58df0e7ca0c59247bbb1478d4e6ec68e260d599e8002c2ad367779439'
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Propshaft
|
2
2
|
|
3
|
-
Propshaft is an asset pipeline library for Rails. It's built for an era where bundling assets to save on HTTP connections is no longer urgent, where JavaScript and CSS are either compiled by dedicated Node.js bundlers or served directly to the browsers, and where increases in bandwidth have made the need for minification less pressing. These factors allow for a dramatically simpler and faster asset pipeline compared to previous options, like Sprockets.
|
3
|
+
Propshaft is an asset pipeline library for Rails. It's built for an era where bundling assets to save on HTTP connections is no longer urgent, where JavaScript and CSS are either compiled by dedicated Node.js bundlers or served directly to the browsers, and where increases in bandwidth have made the need for minification less pressing. These factors allow for a dramatically simpler and faster asset pipeline compared to previous options, like [Sprockets](https://github.com/rails/sprockets-rails).
|
4
4
|
|
5
5
|
So that's what Propshaft doesn't do. Here's what it does provide:
|
6
6
|
|
@@ -12,7 +12,7 @@ So that's what Propshaft doesn't do. Here's what it does provide:
|
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
15
|
-
With Rails 7+, you can start a new application with propshaft using `rails new myapp -a propshaft
|
15
|
+
With Rails 7+, you can start a new application with propshaft using `rails new myapp -a propshaft`.
|
16
16
|
|
17
17
|
|
18
18
|
## Usage
|
@@ -31,7 +31,7 @@ If you need to put multiple files that refer to each other through Propshaft, li
|
|
31
31
|
|
32
32
|
## Migrating from Sprockets
|
33
33
|
|
34
|
-
Propshaft does a lot less than Sprockets, by design, so it might well be a fair bit of work to migrate if it's even desirable. This is particularly true if you rely on Sprockets to provide any form of transpiling, like CoffeeScript or Sass, or if you rely on any gems that do. You'll need to either stop transpiling or use a Node-based transpiler, like those in `jsbundling-rails` and `cssbundling-rails
|
34
|
+
Propshaft does a lot less than Sprockets, by design, so it might well be a fair bit of work to migrate if it's even desirable. This is particularly true if you rely on Sprockets to provide any form of transpiling, like CoffeeScript or Sass, or if you rely on any gems that do. You'll need to either stop transpiling or use a Node-based transpiler, like those in [`jsbundling-rails`](https://github.com/rails/jsbundling-rails) and [`cssbundling-rails`](https://github.com/rails/cssbundling-rails).
|
35
35
|
|
36
36
|
On the other hand, if you're already bundling JavaScript and CSS through a Node-based setup, then Propshaft is going to slot in easily. Since you don't need another tool to bundle or transpile. Just to digest and serve.
|
37
37
|
|
data/lib/propshaft/assembly.rb
CHANGED
@@ -44,9 +44,11 @@ class Propshaft::Assembly
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def reveal
|
47
|
+
def reveal(path_type = :logical_path)
|
48
|
+
path_type = path_type.presence_in(%i[ logical_path path ]) || raise(ArgumentError, "Unknown path_type: #{path_type}")
|
49
|
+
|
48
50
|
load_path.assets.each do |asset|
|
49
|
-
Propshaft.logger.info asset.
|
51
|
+
Propshaft.logger.info asset.send(path_type)
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
data/lib/propshaft/asset.rb
CHANGED
data/lib/propshaft/railtie.rb
CHANGED
@@ -1,16 +1,6 @@
|
|
1
1
|
require "rails"
|
2
|
-
require "rails/railtie"
|
3
2
|
require "active_support/ordered_options"
|
4
3
|
|
5
|
-
# FIXME: There's gotta be a better way than this hack?
|
6
|
-
class Rails::Engine < Rails::Railtie
|
7
|
-
initializer "propshaft.append_assets_path", group: :all do |app|
|
8
|
-
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
|
9
|
-
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
|
10
|
-
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
4
|
module Propshaft
|
15
5
|
class Railtie < ::Rails::Railtie
|
16
6
|
config.assets = ActiveSupport::OrderedOptions.new
|
@@ -22,6 +12,16 @@ module Propshaft
|
|
22
12
|
[ "text/javascript", Propshaft::Compilers::SourceMappingUrls ]
|
23
13
|
]
|
24
14
|
config.assets.sweep_cache = Rails.env.development?
|
15
|
+
config.assets.server = Rails.env.development? || Rails.env.test?
|
16
|
+
|
17
|
+
# Register propshaft initializer to copy the assets path in all the Rails Engines.
|
18
|
+
# This makes possible for us to keep all `assets` config in this Railtie, but still
|
19
|
+
# allow engines to automatically register their own paths.
|
20
|
+
Rails::Engine.initializer "propshaft.append_assets_path", group: :all do |app|
|
21
|
+
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
|
22
|
+
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
|
23
|
+
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
|
24
|
+
end
|
25
25
|
|
26
26
|
config.after_initialize do |app|
|
27
27
|
config.assets.output_path ||=
|
@@ -29,8 +29,10 @@ module Propshaft
|
|
29
29
|
|
30
30
|
app.assets = Propshaft::Assembly.new(app.config.assets)
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
if config.assets.server
|
33
|
+
app.routes.prepend do
|
34
|
+
mount app.assets.server => app.assets.config.prefix
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
ActiveSupport.on_load(:action_view) do
|
@@ -16,6 +16,13 @@ namespace :assets do
|
|
16
16
|
|
17
17
|
desc "Print all the assets available in config.assets.paths"
|
18
18
|
task reveal: :environment do
|
19
|
-
Rails.application.assets.reveal
|
19
|
+
Rails.application.assets.reveal(:logical_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :reveal do
|
23
|
+
desc "Print the full path of assets available in config.assets.paths"
|
24
|
+
task full: :environment do
|
25
|
+
Rails.application.assets.reveal(:path)
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|
data/lib/propshaft/server.rb
CHANGED
@@ -34,7 +34,7 @@ class Propshaft::Server
|
|
34
34
|
private
|
35
35
|
def extract_path_and_digest(env)
|
36
36
|
full_path = Rack::Utils.unescape(env["PATH_INFO"].to_s.sub(/^\//, ""))
|
37
|
-
digest = full_path[/-([0-9a-
|
37
|
+
digest = full_path[/-([0-9a-zA-Z]{7,128})\.(?!digested)[^.]+\z/, 1]
|
38
38
|
path = digest ? full_path.sub("-#{digest}", "") : full_path
|
39
39
|
|
40
40
|
[ path, digest ]
|
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.5.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:
|
11
|
+
date: 2022-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 7.0.0
|
19
|
+
version: 7.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 7.0.0
|
26
|
+
version: 7.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 7.0.0
|
33
|
+
version: 7.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 7.0.0
|
40
|
+
version: 7.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: railties
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 7.0.0
|
47
|
+
version: 7.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 7.0.0
|
54
|
+
version: 7.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rack
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
|
-
rubygems_version: 3.2.
|
115
|
+
rubygems_version: 3.2.32
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Deliver assets for Rails.
|