manifester 0.1.7 → 0.1.8

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +68 -8
  3. data/lib/manifester/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29824867c809881b67054ed4b5afe7da25f2522c8942c2a97ffabc3cb77e318e
4
- data.tar.gz: 0f7e32d8feaf9d0808b4c280ca3ea8b480b2f43ef449e6294f1c2071498df8e4
3
+ metadata.gz: 2711d54f33a2cb64f451cbb1bde44463f7b23cac683526a91263ff96f440d016
4
+ data.tar.gz: 0dd7c6aa348ce3b9ce6275ca208ac5e43ab6090c60133511f722530fdfcad957
5
5
  SHA512:
6
- metadata.gz: 43ec8577fc3597f5ee45875c6d057c8c08da99f437a817fd8239f069925e47dbca35409420a6cf0905ea3928059ed662835ac3192413d937b8723a53516269f3
7
- data.tar.gz: b582bb945ae72312d85ac10ecd117e07faf4061511818281d13d57718e2d1e904a1e89c8c17b976cb10104ccbc8682a56917a9be56d2a9fb8721974bcb65ad4a
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 when we and
6
+ We just needed something that would take the packed files and add it to the layout.
7
7
 
8
- ## Usage
9
- How to use my plugin.
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
- Or install it yourself as:
24
- ```bash
25
- $ gem install manifester
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
- Contribution directions go here.
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).
@@ -1,3 +1,3 @@
1
1
  module Manifester
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
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.7
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-04-14 00:00:00.000000000 Z
11
+ date: 2021-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails