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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 747061130f0677dcd35cb81ddaa587573a8e0c97
4
- data.tar.gz: 1adf1f455ae3f38a2c8631c1a294ab1fb6c8151a
3
+ metadata.gz: c351a7e17bb26cb23f67bfd52355be21091caab6
4
+ data.tar.gz: 3dbff50e1818ba2953a976767fd544a981e40325
5
5
  SHA512:
6
- metadata.gz: 4721693b8b7a9fc1a75d39f5cd0aa7b0c8107b2f31e54b8745041f7473fa19fd4b31432449320361fd5bab295dcb0f97dce426dfbae8fdc323b069c6e4fc2ead
7
- data.tar.gz: 500a27a4e74f77dc1bfed1ef93ca90f66ae9e0428f9cb555137b4e1009df2af20f48a584f5dfc41bc96d29b3364b1c638ef1a6cec3b52a566be5923ac19257b5
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. In CI, we manually run `webpack` to compile the assets to public and set `config.webpack.dev_server.enabled` to false.
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/lgarvey/webpack-rails) gem which inspired this implementation
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/)
@@ -13,6 +13,7 @@ namespace :webpack do
13
13
  raise "Can't find our webpack config file at #{config_file}"
14
14
  end
15
15
 
16
- sh "#{webpack_bin} --bail --config #{config_file}"
16
+ result = `#{webpack_bin} --bail --config #{config_file} 2>&1`
17
+ raise result unless $? == 0
17
18
  end
18
19
  end
@@ -0,0 +1 @@
1
+ require 'webpack/rails'
@@ -21,7 +21,7 @@ module Webpack
21
21
 
22
22
  if ::Rails.configuration.webpack.dev_server.enabled
23
23
  paths.map! do |p|
24
- "http://#{host}:#{port}#{p}"
24
+ "//#{host}:#{port}#{p}"
25
25
  end
26
26
  end
27
27
 
@@ -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
- [paths].flatten.map do |p|
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.get(
56
+ http = Net::HTTP.new(
56
57
  "localhost",
57
- dev_server_path,
58
- ::Rails.configuration.webpack.dev_server.port
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
@@ -1,6 +1,6 @@
1
1
  module Webpack
2
2
  # :nodoc:
3
3
  module Rails
4
- VERSION = "0.9.5"
4
+ VERSION = "0.9.6"
5
5
  end
6
6
  end
@@ -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.5
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: 2015-10-31 00:00:00.000000000 Z
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