webpack_rails 2.0.0 → 2.0.1

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: 24eb2d5b3f17a410dd75aaefd6e0e4203df63f30
4
- data.tar.gz: a2c3d47d9286ffee33128a6489d68e48ffb5427d
3
+ metadata.gz: d2d0ada939f5edb55688dd0f9cdc7fc7b1978a36
4
+ data.tar.gz: 8594f00093d00e47869054500632562d15781ff5
5
5
  SHA512:
6
- metadata.gz: e125bf7ef05f97af37333b81bafcccf0c9f3dc136668d2fbf16222efea388ba0b9475c83197178459879a7a774b9c245389e84db965abea20eebf7125fee456f
7
- data.tar.gz: 1c11739dc521a5c47b1d60e489ef1cc3b3770f0bd5a596a74f57d8c52bb045e15df0c8c2ef585a8330a200e56356e3831d30b58639ae78224c0744a26cf3cf20
6
+ metadata.gz: 5fede1ccbff8d7554256e9996c0a220e399a2cf2c8588c3e18e5a5834c96e7a3b461828dbe495b8776088fc672713f7ecbf2251f7f8167875b2ee7a470052a90
7
+ data.tar.gz: f99da52900194cf2737946b6d24ed33085a33993d02776c0a3bd78d3d352cef56d4cb18e3c0be424c04c023c81bf2c6537d701fd374ad74b9a71a141f068f8a3
@@ -2,5 +2,6 @@ module WebpackRails
2
2
  require_relative './webpack_rails/require_directive_processor'
3
3
  require_relative './webpack_rails/task'
4
4
  require_relative './webpack_rails/processor'
5
+ require_relative './webpack_rails/helper'
5
6
  require_relative './webpack_rails/engine'
6
7
  end
@@ -0,0 +1,8 @@
1
+ module WebpackRails::Config
2
+ DEFAULT_CONFIG = {
3
+ dev_server: false,
4
+ protocol: 'http',
5
+ host: 'localhost',
6
+ port: 9876,
7
+ }
8
+ end
@@ -1,10 +1,15 @@
1
1
  require_relative './sprockets_environment'
2
+ require_relative './helper'
3
+ require_relative './config'
2
4
 
3
5
  module WebpackRails
4
6
  class Engine < ::Rails::Engine
5
7
  engine_name 'webpack'
6
8
 
7
9
  config.webpack_rails = ActiveSupport::OrderedOptions.new
10
+ WebpackRails::Config::DEFAULT_CONFIG.each do |k, v|
11
+ config.webpack_rails.[]= k, v
12
+ end
8
13
 
9
14
  initializer :setup_webpack_rails, after: 'sprockets.environment', group: :all do |app|
10
15
  app.config.assets.configure do |env|
@@ -15,6 +20,12 @@ module WebpackRails
15
20
  end
16
21
  end
17
22
 
23
+ config.after_initialize do
24
+ ActiveSupport.on_load(:action_view) do
25
+ include WebpackRails::Helper
26
+ end
27
+ end
28
+
18
29
  rake_tasks do
19
30
  load 'webpack_rails/webpack.rake'
20
31
  end
@@ -0,0 +1,14 @@
1
+ # view helper to resolve bundle asset file url (falling back to sprockets)
2
+
3
+ module WebpackRails
4
+ module Helper
5
+ def webpack_bundle_asset(bundle_filename)
6
+ webpack_config = Rails.application.config.webpack_rails
7
+ if webpack_config.dev_server
8
+ "#{webpack_config[:protocol]}://#{webpack_config[:host]}:#{webpack_config[:port]}/#{bundle_filename}"
9
+ else
10
+ asset_path bundle_filename
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack_rails",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "",
5
5
  "main": "webpack-dev-server.js",
6
6
  "scripts": {
@@ -2,23 +2,17 @@ require 'sprockets'
2
2
  require 'webpack_rails/sprockets_cached_environment'
3
3
  require 'webpack_rails/require_directive_processor'
4
4
  require 'webpack_rails/processor'
5
+ require 'webpack_rails/config'
5
6
 
6
7
  module WebpackRails
7
8
  class SprocketsEnvironment
8
- DEFAULT_WEBPACK_TASK_CONFIG = {
9
- dev_server: false,
10
- protocol: 'http',
11
- host: 'localhost',
12
- port: 9876,
13
- }
14
-
15
9
  module EnvironmentWebpackInstanceMethods
16
10
  def webpack_task_config=(new_webpack_task_config)
17
11
  @webpack_task_config = new_webpack_task_config
18
12
  end
19
13
 
20
14
  def webpack_task_config
21
- @webpack_task_config.merge(DEFAULT_WEBPACK_TASK_CONFIG).merge(@webpack_task_config)
15
+ WebpackRails::Config::DEFAULT_CONFIG.clone.merge(@webpack_task_config)
22
16
  end
23
17
 
24
18
  def install_webpack_task_processors!
@@ -66,7 +66,7 @@ module WebpackRails
66
66
  def build_once(webpack_task_config)
67
67
  WebpackRails::Task.with_app_node_path do
68
68
  webpack_cmd_script = `#{WebpackRails::Task.node_command} -e "process.stdout.write(require.resolve('webpack/bin/webpack.js'))"`
69
- system "#{WebpackRails::Task.node_command} #{webpack_cmd_script} --config #{webpack_task_config[:webpack_config_file]}"
69
+ system "#{WebpackRails::Task.node_command} '#{webpack_cmd_script}' --config #{webpack_task_config[:webpack_config_file]}"
70
70
  end
71
71
  end
72
72
 
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: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Friend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-31 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: node_task
@@ -52,7 +52,9 @@ extra_rdoc_files: []
52
52
  files:
53
53
  - lib/webpack_rails.rb
54
54
  - lib/webpack_rails/ErrorMessagePlugin.js
55
+ - lib/webpack_rails/config.rb
55
56
  - lib/webpack_rails/engine.rb
57
+ - lib/webpack_rails/helper.rb
56
58
  - lib/webpack_rails/log.js
57
59
  - lib/webpack_rails/node_modules/cors/CONTRIBUTING.md
58
60
  - lib/webpack_rails/node_modules/cors/LICENSE