webpack-rails 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -3
- data/lib/tasks/webpack.rake +2 -1
- data/lib/webpack-rails.rb +1 -0
- data/lib/webpack/rails/helper.rb +1 -1
- data/lib/webpack/rails/manifest.rb +8 -6
- data/lib/webpack/rails/version.rb +1 -1
- data/lib/webpack/railtie.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c351a7e17bb26cb23f67bfd52355be21091caab6
|
4
|
+
data.tar.gz: 3dbff50e1818ba2953a976767fd544a981e40325
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90a622102561e20434d6b79101d79b5ee2116adcf2ee972183a0684d789a1bb9e5d858e1eded1f5eed3be28160e076698a69667fab8c486316de5269e0889a4b
|
7
|
+
data.tar.gz: c25685a1f26ec35f73ba68d636bba69da3c065872e9216473e2373364fd0be8f827ed0d6fec159001557a96a41d4ea4762008f5d850b9b557349305114c50ffb
|
data/README.md
CHANGED
@@ -38,6 +38,14 @@ To add your webpacked javascript in to your app, add the following to the `<head
|
|
38
38
|
|
39
39
|
Take note of the splat (`*`): `webpack_asset_paths` returns an array, as one entry point can map to multiple paths, especially if hot reloading is enabled in Webpack.
|
40
40
|
|
41
|
+
#### Use with webpack-dev-server live reload
|
42
|
+
|
43
|
+
If you're using the webpack dev server's live reload feature (not the React hot reloader), you'll also need to include the following in your layout template:
|
44
|
+
|
45
|
+
``` html
|
46
|
+
<script src="http://localhost:3808/webpack-dev-server.js"></script>
|
47
|
+
```
|
48
|
+
|
41
49
|
### How it works
|
42
50
|
|
43
51
|
Have a look at the files in the `examples` directory. Of note:
|
@@ -50,14 +58,22 @@ Have a look at the files in the `examples` directory. Of note:
|
|
50
58
|
|
51
59
|
* Webpack configuration lives in `config/webpack.config.js`
|
52
60
|
* Webpack & Webpack Dev Server binaries are in `node_modules/.bin/`
|
53
|
-
* Webpack Dev Server will run on port 3808 on localhost
|
61
|
+
* Webpack Dev Server will run on port 3808 on localhost via HTTP
|
54
62
|
* Webpack Dev Server is enabled in development & test, but not in production
|
55
63
|
* Webpacked assets will be compiled to `public/webpack`
|
56
64
|
* The manifest file is named `manifest.json`
|
57
65
|
|
58
66
|
### Working with browser tests
|
59
67
|
|
60
|
-
In development, we make sure that the `webpack-dev-server` is running when browser tests are running.
|
68
|
+
In development, we make sure that the `webpack-dev-server` is running when browser tests are running.
|
69
|
+
|
70
|
+
#### Continuous Integration
|
71
|
+
|
72
|
+
In CI, we manually run `webpack` to compile the assets to public and set `config.webpack.dev_server.enabled` to `false` in our `config/environments/test.rb`:
|
73
|
+
|
74
|
+
``` ruby
|
75
|
+
config.webpack.dev_server.enabled = !ENV['CI']
|
76
|
+
```
|
61
77
|
|
62
78
|
### Production Deployment
|
63
79
|
|
@@ -80,6 +96,6 @@ Please ensure that pull requests pass both rubocop & rspec. New functionality sh
|
|
80
96
|
|
81
97
|
## Acknowledgements
|
82
98
|
|
83
|
-
* Len Garvey for his [webpack-rails](https://github.com/
|
99
|
+
* Len Garvey for his [webpack-rails](https://github.com/lengarvey/webpack-rails) gem which inspired this implementation
|
84
100
|
* Sebastian Porto for [Rails with Webpack](https://reinteractive.net/posts/213-rails-with-webpack-why-and-how)
|
85
101
|
* Clark Dave for [How to use Webpack with Rails](http://clarkdave.net/2015/01/how-to-use-webpack-with-rails/)
|
data/lib/tasks/webpack.rake
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require 'webpack/rails'
|
data/lib/webpack/rails/helper.rb
CHANGED
@@ -21,8 +21,9 @@ module Webpack
|
|
21
21
|
def asset_paths(source)
|
22
22
|
paths = manifest["assetsByChunkName"][source]
|
23
23
|
if paths
|
24
|
-
# Can be either a string or an array of strings
|
25
|
-
|
24
|
+
# Can be either a string or an array of strings.
|
25
|
+
# Do not include source maps as they are not javascript
|
26
|
+
[paths].flatten.reject { |p| p =~ /.*\.map$/ }.map do |p|
|
26
27
|
"/#{::Rails.configuration.webpack.public_path}/#{p}"
|
27
28
|
end
|
28
29
|
else
|
@@ -52,11 +53,12 @@ module Webpack
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def load_dev_server_manifest
|
55
|
-
Net::HTTP.
|
56
|
+
http = Net::HTTP.new(
|
56
57
|
"localhost",
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
::Rails.configuration.webpack.dev_server.port)
|
59
|
+
http.use_ssl = ::Rails.configuration.webpack.dev_server.https
|
60
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
61
|
+
http.get(dev_server_path).body
|
60
62
|
rescue => e
|
61
63
|
raise ManifestLoadError.new("Could not load manifest from webpack-dev-server at #{dev_server_url} - is it running, and is stats-webpack-plugin loaded?", e)
|
62
64
|
end
|
data/lib/webpack/railtie.rb
CHANGED
@@ -18,6 +18,7 @@ module Webpack
|
|
18
18
|
config.webpack.dev_server = ActiveSupport::OrderedOptions.new
|
19
19
|
config.webpack.dev_server.host = 'localhost'
|
20
20
|
config.webpack.dev_server.port = 3808
|
21
|
+
config.webpack.dev_server.https = false # note - this will use OpenSSL::SSL::VERIFY_NONE
|
21
22
|
config.webpack.dev_server.binary = 'node_modules/.bin/webpack-dev-server'
|
22
23
|
config.webpack.dev_server.enabled = !::Rails.env.production?
|
23
24
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpack-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Pearson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- example/webpack.config.js
|
42
42
|
- lib/generators/webpack_rails/install_generator.rb
|
43
43
|
- lib/tasks/webpack.rake
|
44
|
+
- lib/webpack-rails.rb
|
44
45
|
- lib/webpack/rails.rb
|
45
46
|
- lib/webpack/rails/helper.rb
|
46
47
|
- lib/webpack/rails/manifest.rb
|