webpacked 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82d8ae7b6dbf8f18a719a897da96f9d1fec6bc15
4
- data.tar.gz: 472fa0e29f7111b049825b971e22cbcb219f55f6
3
+ metadata.gz: 649d7eabca860160f40e8da0527555cb2b50acce
4
+ data.tar.gz: 60581482222323ef7fadc93779297be0eca7e3bc
5
5
  SHA512:
6
- metadata.gz: c55ea3ab94b83d5eaebf41a4349ec9328ee95256ef15b2a6f75497d55407a7cbdb342be4dc98205d39af663c31be66e895f36fb2d933272f0f7ba2b4bd059b03
7
- data.tar.gz: 954e07ec3810d4500cf4a894c82705e71cf43b52b18e62aae6b31066c5289229aad42b54f01acf96774dc741a7536a8e19204049bfcd4542fe1ded30b94dbc62
6
+ metadata.gz: 27405dee478e6919ee0408ece1e495b0f3597af6b3d6390b907d480b095429b03503b1db1b495f0f521f6ddce10d2af675b31dd2f1b62f30921be10555ab2a92
7
+ data.tar.gz: 445c317d8b5cd3fcbdca8204c7c1521dd414b67bf9b199064c19baeed9dcd9d6089af88a32e935bab425ca847486b46fef1d052d34fbf56b7e3d744f15367596
data/README.md CHANGED
@@ -53,10 +53,10 @@ To add webpacked assets in to your application, use following helpers:
53
53
  <!DOCTYPE html>
54
54
  <html>
55
55
  <head>
56
- <%= webpacked_css_tags 'application' %>
56
+ <%== webpacked_css_tags 'application' %>
57
57
  </head>
58
58
  <body>
59
- <%= webpacked_js_tags 'application' %>
59
+ <%== webpacked_js_tags 'application' %>
60
60
  </body>
61
61
  </html>
62
62
  ```
@@ -82,13 +82,13 @@ class FooController < ApplicationController
82
82
  end
83
83
 
84
84
  class BarController < ApplicationController
85
- webpacked_entry "bar"
85
+ webpacked_entry %w(vendor bar) # accepts multiple entry points as well
86
86
  end
87
87
  ```
88
88
 
89
89
  ```erb
90
- <%= webpacked_css_tags webpacked_entry_name %>
91
- <%= webpacked_js_tags webpacked_entry_name %>
90
+ <%== webpacked_css_tags webpacked_entry_name %>
91
+ <%== webpacked_js_tags webpacked_entry_name %>
92
92
  ```
93
93
 
94
94
  In the example above the decision which entry point to use comes in controllers instead views. Therefore in layout we can use a common `webpacked_entry_name` helper method. Notice that `webpacked_entry` in `ApplicationController` will be used if concrete controller does not define its own entry.
@@ -98,7 +98,7 @@ In the example above the decision which entry point to use comes in controllers
98
98
  If you don't like none of the mentioned above, you can use more generic helpers to access webpack manifest:
99
99
 
100
100
  * `asset_tag(entry, kind)` return include tags for entry point `entry`; `kind` could be `:js` or `:css`
101
- * `webpacked_asset_path(entry, kind = nil)` return only assets path for given entry
101
+ * `webpacked_asset_path(entry, kind = nil)` return only assets path for given entry (or entries if array given)
102
102
 
103
103
  Be aware that common entry point is not included by these methods. So if you use common chunks optimization do not forget to include `common` (or whatever name you pick) entry point manually.
104
104
 
@@ -1,24 +1,27 @@
1
1
  module Webpacked
2
2
  # Add new view helpers
3
3
  module Helper
4
- # Return +javascript_include_tag+ for entry point.
4
+ # Return +javascript_include_tag+ for entry points.
5
5
  # Also common Javascript file could be included
6
- def webpacked_js_tags(entry)
7
- webpacked_tags entry, :js
6
+ def webpacked_js_tags(entries)
7
+ webpacked_tags entries, :js
8
8
  end
9
9
 
10
- # Return +stylesheet_link_tag+ for entry point.
10
+ # Return +stylesheet_link_tag+ for entry points.
11
11
  # Also common CSS file could be included
12
- def webpacked_css_tags(entry)
13
- webpacked_tags entry, :css
12
+ def webpacked_css_tags(entries)
13
+ webpacked_tags entries, :css
14
14
  end
15
15
 
16
- # Return include tags for entry point by given asset kind.
16
+ # Return include tags for entry points by given asset kind.
17
17
  # Also common file could be included
18
- def webpacked_tags(entry, kind)
18
+ def webpacked_tags(entries, kind)
19
19
  common_entry = ::Rails.configuration.webpacked.common_entry_name
20
20
  common_bundle = asset_tag(common_entry, kind)
21
- page_bundle = asset_tag(entry, kind)
21
+ page_bundle = Array(entries).reduce('') do |memo, entry|
22
+ tag = asset_tag(entry, kind)
23
+ memo << tag if tag
24
+ end
22
25
  common_bundle ? common_bundle + page_bundle : page_bundle
23
26
  end
24
27
 
@@ -1,3 +1,3 @@
1
1
  module Webpacked
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacked
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Garbuz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.6.6
90
+ rubygems_version: 2.6.8
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Easy webpack and Rails integration