manifester 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +68 -8
- data/lib/manifester/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: 2711d54f33a2cb64f451cbb1bde44463f7b23cac683526a91263ff96f440d016
|
4
|
+
data.tar.gz: 0dd7c6aa348ce3b9ce6275ca208ac5e43ab6090c60133511f722530fdfcad957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa700a55fc8603fd1b77e9e3e737870474a9573e90630333b213b619c575c445c2b9337d97a5d6396dd664c2d7884ab544929fe811dcfe9334d1fff0a14ad003
|
7
|
+
data.tar.gz: 96e262a0e445bdbf83bef0e68fa086402fce68655be1eec23a11b66c5ce5074416e56dbe5a34d09932d28a8e10fdd1413ce16ca7c1d1835cc32ca76ccb03827e
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# Manifester
|
2
|
-
Manifester was born from the need to ship webpacker generated assets without webpacker.
|
2
|
+
Manifester was born from the need to ship webpacker generated assets without webpacker for our Rails engines.
|
3
3
|
|
4
4
|
When we first shipped [Avo](https://github.com/avo-hq/avo) we shipped it with the whole Webpacker pipeline. That meant rebuilding the assets on every deploy of the parent app and other nasty unwanted behaviors (conflicting pipelines, etc.).
|
5
5
|
|
6
|
-
We just needed something that would take the packed files
|
6
|
+
We just needed something that would take the packed files and add it to the layout.
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
Most of the code has been extracted from [webpacker](https://github.com/rails/webpacker/).
|
9
|
+
|
10
|
+
**Important**: I assume you have followed [this](https://github.com/rails/webpacker/blob/5-x-stable/docs/engines.md) guide to add webpacker to your engine.
|
10
11
|
|
11
12
|
## Installation
|
12
13
|
Add this line to your application's Gemfile:
|
@@ -20,13 +21,72 @@ And then execute:
|
|
20
21
|
$ bundle
|
21
22
|
```
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
```ruby
|
25
|
+
# your engine's gemspec
|
26
|
+
spec.add_dependency "manifester"
|
27
|
+
```
|
28
|
+
|
29
|
+
Instantiate the plugin in your main file using a few config values. Also have the webpacker instance side by side for development.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# lib/your_engine.rb
|
33
|
+
|
34
|
+
module YourEngine
|
35
|
+
ROOT_PATH = Pathname.new(File.join(__dir__, ".."))
|
36
|
+
IN_DEVELOPMENT = ENV["ENGINE_IN_DEVELOPMENT"] == "1"
|
37
|
+
|
38
|
+
class << self
|
39
|
+
# have a webpacker instance for your development env
|
40
|
+
def webpacker
|
41
|
+
@webpacker ||= ::Webpacker::Instance.new(
|
42
|
+
root_path: ROOT_PATH,
|
43
|
+
config_path: ROOT_PATH.join("config/webpacker.yml")
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def manifester
|
48
|
+
@manifester ||= ::Manifester::Instance.new(
|
49
|
+
root_path: ROOT_PATH,
|
50
|
+
public_output_dir: "your-engine-packs", # the path where your packed files live
|
51
|
+
cache_manifest: Rails.env.production?,
|
52
|
+
fallback_to_webpacker: -> { YourEngine::IN_DEVELOPMENT || Rails.env.test? } # fallback to webpacker in development
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
26
57
|
```
|
27
58
|
|
59
|
+
In your application helper override the `current_webpacker_instance` method to return your engine's instance **only in development** and the parent app webpacker in production.
|
60
|
+
|
61
|
+
Add the `current_manifester_instance` method.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
# app/helpers/your_engine/application_helper
|
65
|
+
module YourEngine
|
66
|
+
module ApplicationHelper
|
67
|
+
include ::Manifester::Helper # add the manifester helpers
|
68
|
+
|
69
|
+
# add your current webpacker instance for development
|
70
|
+
def current_webpacker_instance
|
71
|
+
return YourEngine.webpacker if YourEngine::IN_DEVELOPMENT || Rails.env.test?
|
72
|
+
|
73
|
+
super
|
74
|
+
end
|
75
|
+
|
76
|
+
def current_manifester_instance
|
77
|
+
YourEngine.manifester
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
## Usage
|
84
|
+
|
85
|
+
Now you should have webpacker work as usual in development and testing environments and manifester in the production env.
|
86
|
+
|
28
87
|
## Contributing
|
29
|
-
|
88
|
+
|
89
|
+
Clone the repo, run `bundle install`.
|
30
90
|
|
31
91
|
## License
|
32
92
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/manifester/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manifester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|