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 +4 -4
- data/README.md +6 -6
- data/lib/webpacked/helper.rb +12 -9
- data/lib/webpacked/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 649d7eabca860160f40e8da0527555cb2b50acce
|
4
|
+
data.tar.gz: 60581482222323ef7fadc93779297be0eca7e3bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
56
|
+
<%== webpacked_css_tags 'application' %>
|
57
57
|
</head>
|
58
58
|
<body>
|
59
|
-
|
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
|
85
|
+
webpacked_entry %w(vendor bar) # accepts multiple entry points as well
|
86
86
|
end
|
87
87
|
```
|
88
88
|
|
89
89
|
```erb
|
90
|
-
|
91
|
-
|
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
|
|
data/lib/webpacked/helper.rb
CHANGED
@@ -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
|
4
|
+
# Return +javascript_include_tag+ for entry points.
|
5
5
|
# Also common Javascript file could be included
|
6
|
-
def webpacked_js_tags(
|
7
|
-
webpacked_tags
|
6
|
+
def webpacked_js_tags(entries)
|
7
|
+
webpacked_tags entries, :js
|
8
8
|
end
|
9
9
|
|
10
|
-
# Return +stylesheet_link_tag+ for entry
|
10
|
+
# Return +stylesheet_link_tag+ for entry points.
|
11
11
|
# Also common CSS file could be included
|
12
|
-
def webpacked_css_tags(
|
13
|
-
webpacked_tags
|
12
|
+
def webpacked_css_tags(entries)
|
13
|
+
webpacked_tags entries, :css
|
14
14
|
end
|
15
15
|
|
16
|
-
# Return include tags for entry
|
16
|
+
# Return include tags for entry points by given asset kind.
|
17
17
|
# Also common file could be included
|
18
|
-
def webpacked_tags(
|
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
|
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
|
|
data/lib/webpacked/version.rb
CHANGED
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.
|
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-
|
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.
|
90
|
+
rubygems_version: 2.6.8
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Easy webpack and Rails integration
|