webpacker_lite 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64e87e565a455af62c43a863fcf44063208c83fc
4
- data.tar.gz: d4c5089867ebcdd40cf3c9a274477663f236e54b
3
+ metadata.gz: 8065d14438ac62efccda228de96db73947f6e85b
4
+ data.tar.gz: 20969437cadd20e89abcab5205b9fff66c2906f9
5
5
  SHA512:
6
- metadata.gz: b7f508d5f1c97d0c770f80cb38be7bacae6d78f7c0ac004bcd3ca0ff35f2116fdcf23058f4ea9612d2a53ee1e8c4178aa5c25e51ed8b9fe3f96f2ad948b4cbf0
7
- data.tar.gz: b5edde0f90ce1b0f89b8a09ccff11397133438464fae475e93d23ad7a4817ba63d46284aaf2439db099c21f4539a42fe5cfcda912856e632c15842614e29c066
6
+ metadata.gz: 81d6667497a72da748c52ee6d8ce7e9ba12822f33b8d57ca0c1db403c2cc5cb2a34caec58b2abe74426eb689083c4f3e7816259240f9526a02b67fb10167cea6
7
+ data.tar.gz: f21a6493a8f68ad21c51faf22f52ab09427a840b8a50b378bf734f6e558d57bc05f837ba0db27c614a07d5488de929d45214c757557f3d872ebea7c512919ab8
@@ -5,6 +5,13 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]
5
5
 
6
6
  ## [Unreleased]
7
7
  *Please add entries here for your pull requests.*
8
+ ## [2.1.0] - 2017-07-18
9
+ ### Added
10
+ * Expose helper pack_path for server rendering so asset_path is not called, so that a CDN is never used for server rendering in React on Rails. [#23](https://github.com/shakacode/webpacker_lite/pull/23) by [justin808](https://github.com/justin808).
11
+
12
+ ## [2.0.4] - 2017-05-29
13
+ ### Fixed
14
+ * Code handles case of missing file and mtime. [#15](https://github.com/shakacode/webpacker_lite/pull/15) by [justin808](https://github.com/justin808).
8
15
 
9
16
  ## [2.0.3] - 2017-05-29
10
17
  ### Fixed
@@ -34,7 +41,8 @@ All in [#9](https://github.com/shakacode/webpacker_lite/pull/9) by [justin808](h
34
41
  ## [1.0.0] - 2017-05-03
35
42
  Initial release
36
43
 
37
- [Unreleased]: https://github.com/shakacode/webpacker_lite/compare/2.0.3...master
44
+ [Unreleased]: https://github.com/shakacode/webpacker_lite/compare/2.0.4...master
45
+ [2.0.4]: https://github.com/shakacode/react_on_rails/compare/2.0.3...2.0.4
38
46
  [2.0.3]: https://github.com/shakacode/react_on_rails/compare/2.0.2...2.0.3
39
47
  [2.0.2]: https://github.com/shakacode/react_on_rails/compare/2.0.1...2.0.2
40
48
  [2.0.1]: https://github.com/shakacode/react_on_rails/compare/2.0.0...2.0.1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker_lite (2.0.4)
4
+ webpacker_lite (2.1.0)
5
5
  activesupport (>= 4.2)
6
6
  multi_json (~> 1.2)
7
7
  railties (>= 4.2)
@@ -137,4 +137,4 @@ DEPENDENCIES
137
137
  webpacker_lite!
138
138
 
139
139
  BUNDLED WITH
140
- 1.15.0
140
+ 1.15.1
data/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
  # Webpacker Lite
2
- ![Gem Version](https://badge.fury.io/rb/webpacker_lite.svg)
2
+ ![Gem Version](https://badge.fury.io/rb/webpacker_lite.svg) [![Build Status](https://travis-ci.org/shakacode/webpacker_lite.svg?branch=master)](https://travis-ci.org/shakacode/webpacker_lite)
3
3
 
4
- **VERSION 8 of [React on Rails](https://github.com/shakacode/react_on_rails) is super close!!!** [VERSION 8.0.0-beta.3](https://rubygems.org/gems/react_on_rails/versions/8.0.0.beta.3) has shipped with [webpacker_lite](https://github.com/shakacode/webpacker_lite) support! Please try [the 8.0.0-beta.3 beta](https://rubygems.org/gems/react_on_rails/versions/8.0.0.beta.3) and please report issues! We're **SUPER** close as we've also upgraded the [shakacode/react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) with [PR #395](https://github.com/shakacode/react-webpack-rails-tutorial/pull/395). That PR shows the changes needed to go to Webpacker Lite.
4
+ *A slimmer version of Webpacker*
5
5
 
6
+ We will soon merge Webpacker Lite changes back into [Webpacker, per this discussion](https://github.com/rails/webpacker/issues/464#issuecomment-310986140). Any changes will be minor if you're using Webpacker Lite. In the meantime, we have something _stable_ for React on Rails projects!
6
7
 
7
- *A slimmer version of Webpacker*
8
+ ------
8
9
 
9
10
  Webpacker Lite provides similar webpack enabled view helpers from [Webpacker](https://github.com/rails/webpacker).
10
- [React on Rails](https://github.com/shakacode/react_on_rails) version 8 and greater defaults to using Webpacker Lite.
11
11
 
12
12
  For example, these view helpers allow your application's layout to easily reference JavaScript and CSS files created by your Webpack setup, taking into account differences in the Rails environments. With these helpers, there is no reason for Webpack created assets to run through the [Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html), as was done in React on Rails 7.x and earlier.
13
13
 
14
+ [React on Rails](https://github.com/shakacode/react_on_rails) version 8 and greater defaults to using Webpacker Lite. You may use this gem outside of React on Rails projects.
15
+
14
16
  If you like this project, show your support by giving us a star!
15
17
 
16
18
  # Why Fork?
@@ -19,20 +21,19 @@ If you like this project, show your support by giving us a star!
19
21
 
20
22
  [Albert Einstein on Wikiquote](https://en.wikiquote.org/wiki/Albert_Einstein)
21
23
 
22
- Why did [ShakaCode](http://www.shakacode.com) fork [rails/webpacker](https://github.com/rails/webpacker)? For [react_on_rails](https://github.com/shakacode/react_on_rails), we wanted a simpler configuration to get the core functionality needed. You configure 2 things:
24
+ Why did [ShakaCode](http://www.shakacode.com) fork [rails/webpacker](https://github.com/rails/webpacker)?
23
25
 
24
- 1. Name of the manifest file.
25
- 2. The directory within `/public` where Webpack will create the manifest and output file.
26
+ 3 reasons:
26
27
 
27
- Then you need to configure your Webpack to generate a simple manifest that maps the base output names to the possibly fingerprinted versions. Note, unlike Webpacker, Webpacker Lite wants your manifest to **NOT** contain any host information.
28
+ 1. React on Rails needed only the helpers in Webpacker to obtain the correct file path or relative URL to Webpack created assets, given different Rails environments, fingerprinting of assets, hot-reloading, etc.
29
+ 2. We preferred a simpler configuration to get the core functionality needed. You configure just one thing: The directory within `/public` where Webpack will create the manifest and output file. Then you configure your Webpack config to generate a simple manifest that maps the base output names to the possibly fingerprinted versions. Note, unlike Webpacker, Webpacker Lite wants your manifest to **NOT** contain any host information.
30
+ 3. We needed the ability to quickly make changes needed by [react_on_rails](https://github.com/shakacode/react_on_rails)
28
31
 
29
- Optionally, you can configure the name of the server and port for hot reloading, and if hot reloading is the default for a given Rails.env.
30
-
31
- For more details on how this project differs from Webpacker and why we forked, please see [Webpacker Lite: Why Did We Fork Webpacker?](https://medium.com/@railsonmaui/webpacker-lite-why-did-we-fork-webpacker-ee3305688d66)
32
+ For more details on how this project differs from Webpacker and why we forked, please see [Webpacker Lite: Why Fork Webpacker?](https://blog.shakacode.com/webpacker-lite-why-fork-webpacker-f0a7707fac92).
32
33
 
33
34
  # NEWS
34
35
 
35
- * 2017-05-03: React on Rails 8.0.0 beta defaults to using webpacker_lite.
36
+ * 2017-05-29: React on Rails 8.0.0 shipped, defaulting to webpacker_lite.
36
37
 
37
38
  ## Installation
38
39
 
@@ -40,9 +41,8 @@ The best way to see the installation of webpacker_lite is to use the generator f
40
41
 
41
42
  ## Overview
42
43
 
43
- 1. Configure the `config/webpacker_lite.yml` file, as described below. You will specify the name of the manifest file and the output directory used by step 2.
44
- 2. Use the [webpack-manifest-plugin](https://www.npmjs.com/package/webpack-manifest-plugin) to generate a manifest
45
- in the output directory (`webpack_public_output_dir`) that you configured in your `/config/webpacker_lite.yml` file.
44
+ 1. Configure the `config/webpacker_lite.yml` file, as described below. You will specify the name of the manifest file and the output directory used by step 2. The directories you specify are within your `/public` directory.
45
+ 2. Configure Webpack to use an output path that matches your (`webpack_public_output_dir`) that you configured in your `/config/webpacker_lite.yml`. Use the [webpack-manifest-plugin](https://www.npmjs.com/package/webpack-manifest-plugin) to generate a manifest.
46
46
  3. Use the view helpers on your layouts to provide the webpack generated files. Note, these are the same names used by [rails/webpacker](https://github.com/rails/webpacker).
47
47
  These `output` names are **NOT** the actual file names, as the file name may have a [fingerprint](http://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care-questionmark).
48
48
  ```erb
@@ -63,12 +63,12 @@ Webpacker Lite takes one configuration file: `config/webpacker_lite.yml` used to
63
63
 
64
64
  ### Mandatory Configuration within `config/webpacker_lite.yml`
65
65
 
66
- 1. `manifest`: The manifest file name
67
66
  1. `webpack_public_output_dir`: The output directory of both the manifest and the webpack static generated files within the `/public` directory.
68
67
 
69
68
  Note, placing output files within the Rails `/public` directory is not configurable.
70
69
 
71
70
  ### Optional Configuration within `config/webpacker_lite.yml`
71
+ 1. `manifest`: The manifest file name
72
72
  1. `hot_reloading_host`: The name of the hot reloading `webpack-dev-server` including the port
73
73
  2. `hot_reloading_enabled_by_default`: If hot reloading should default to true
74
74
 
@@ -155,6 +155,8 @@ for an asset used in your pack code you can reference them like this in your vie
155
155
  <% # real file path "public/webpack/calendar.png" /> %>
156
156
  ```
157
157
 
158
+ The `pack_path` is the same as the `asset_pack_path` except that the Rails `asset_path` is not called on the file name. This is used by server rendering, as the `asset_path` is designed for browsers to access assets.
159
+
158
160
  ## Webpack Helper
159
161
  You may use the [React on Rails NPM Package](https://www.npmjs.com/package/react-on-rails), [react-on-rails/webpackConfigLoader](https://github.com/shakacode/react_on_rails/blob/master/webpackConfigLoader.js) to provide your Webpack config with easy access to the YAML settings. Even if you don't use the NPM package, you can use that file to inspire your Webpack configuration.
160
162
 
@@ -176,7 +178,7 @@ RAILS_ENV=test rake webpacker_lite:clobber
176
178
  ## Differences from Webpacker
177
179
 
178
180
  1. Configuration setup of an optional single file `/config/webpacker_lite.yml`
179
- 2. Webpacker helpers expect the manifest to contain the server URL when hot reloading. Webpacker Lite expects the manifest to never contain any host information.
181
+ 2. Webpacker helpers expect the manifest to contain the server URL when hot reloading. Webpacker Lite expects the manifest **to never contain any host information**.
180
182
 
181
183
  ## Hot Reloading
182
184
 
@@ -186,8 +188,6 @@ RAILS_ENV=test rake webpacker_lite:clobber
186
188
  ```erb
187
189
  <%= stylesheet_pack_tag('main', enabled_when_hot_loading: true) %> <% # Default is false %>
188
190
  ```
189
-
190
-
191
191
 
192
192
  ## Prerequisites
193
193
  * Ruby 2+
@@ -12,9 +12,20 @@ module WebpackerLite::Helper
12
12
  # In production mode:
13
13
  # <%= asset_pack_path 'calendar.css' %> # => "/public/webpack/production/calendar-1016838bab065ae1e122.css"
14
14
  def asset_pack_path(name, **options)
15
+ pack_path = pack_path(name)
16
+ asset_path(pack_path, **options)
17
+ end
18
+
19
+ # Computes the full path for a given webpacker asset.
20
+ # Return relative path using manifest.json and passes it to asset_url helper
21
+ # Examples:
22
+ #
23
+ # In production mode:
24
+ # <%= asset_pack_path 'calendar.css' %> # => "webpack/production/calendar-1016838bab065ae1e122.css"
25
+ def pack_path(name)
15
26
  path = WebpackerLite::Configuration.base_path
16
27
  file = WebpackerLite::Manifest.lookup(name)
17
- asset_path("#{path}/#{file}", **options)
28
+ "#{path}/#{file}"
18
29
  end
19
30
 
20
31
  # Creates a script tag that references the named pack file, as compiled by Webpack.
@@ -1,3 +1,3 @@
1
1
  module WebpackerLite
2
- VERSION = "2.0.4".freeze
2
+ VERSION = "2.1.0".freeze
3
3
  end
@@ -6,6 +6,11 @@ class HelperTest < ActionView::TestCase
6
6
  @view.extend WebpackerLite::Helper
7
7
  end
8
8
 
9
+ def test_pack_path
10
+ assert_equal @view.pack_path("bootstrap.js"), "/webpack/test/bootstrap-300631c4f0e0f9c865bc.js"
11
+ assert_equal @view.pack_path("bootstrap.css"), "/webpack/test/bootstrap-c38deda30895059837cf.css"
12
+ end
13
+
9
14
  def test_asset_pack_path
10
15
  assert_equal @view.asset_pack_path("bootstrap.js"), "/webpack/test/bootstrap-300631c4f0e0f9c865bc.js"
11
16
  assert_equal @view.asset_pack_path("bootstrap.css"), "/webpack/test/bootstrap-c38deda30895059837cf.css"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson, Justin Gordon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-30 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.6.11
128
+ rubygems_version: 2.6.12
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Asset Helpers for Webpack