repack 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 +4 -4
- data/README.md +1 -1
- data/Rakefile +2 -4
- data/example/boilerplate/views/rails_view.html.haml +4 -0
- data/lib/generators/repack/install_generator.rb +1 -20
- data/lib/generators/repack/view_generator.rb +9 -3
- data/lib/repack.rb +1 -1
- data/lib/repack/helper.rb +32 -0
- data/lib/repack/manifest.rb +87 -0
- data/lib/repack/rails.rb +2 -0
- data/lib/repack/railtie.rb +33 -0
- data/lib/repack/version.rb +3 -0
- metadata +7 -6
- data/lib/webpack/rails.rb +0 -2
- data/lib/webpack/rails/react/helper.rb +0 -36
- data/lib/webpack/rails/react/manifest.rb +0 -91
- data/lib/webpack/rails/react/version.rb +0 -8
- data/lib/webpack/railtie.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d7448ed529be30cd53fdd1ba62d2a18bf59e607
|
4
|
+
data.tar.gz: 70cee6ab8e90ed36202d3d050ab4137aa55302e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3327ba53a50986b3fead93997c37e31704d7efaff4c3024f5494a4b3998a4b5300ea6ea07ba756e1c5e3789c8d24fe61138cc1c9d3b7b8ce7b1e47ef31335ed9
|
7
|
+
data.tar.gz: 204a26b9b2559112d226b7268d7a95373de60f3b77637eb4d427634113d258c25bd7ca7f3ef6edc0ac8c9305d96fd421cc2b8b3f7de5923307dcecf65be96aa9
|
data/README.md
CHANGED
@@ -120,7 +120,7 @@ A view generator has been added.
|
|
120
120
|
|
121
121
|
Pull requests & issues welcome. Advice & criticism regarding webpack config approach also welcome.
|
122
122
|
|
123
|
-
Please ensure that pull requests pass
|
123
|
+
Please ensure that pull requests pass rspec. New functionality should be discussed in an issue first.
|
124
124
|
|
125
125
|
## Acknowledgements
|
126
126
|
|
data/Rakefile
CHANGED
@@ -6,14 +6,12 @@ end
|
|
6
6
|
|
7
7
|
require 'rdoc/task'
|
8
8
|
require 'rspec/core/rake_task'
|
9
|
-
require 'rubocop/rake_task'
|
10
9
|
|
11
|
-
RuboCop::RakeTask.new
|
12
10
|
RSpec::Core::RakeTask.new(:spec)
|
13
11
|
|
14
12
|
RDoc::Task.new(:rdoc) do |rdoc|
|
15
13
|
rdoc.rdoc_dir = 'rdoc'
|
16
|
-
rdoc.title = '
|
14
|
+
rdoc.title = 'Repack'
|
17
15
|
rdoc.options << '--line-numbers'
|
18
16
|
rdoc.rdoc_files.include('README.md')
|
19
17
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
@@ -21,4 +19,4 @@ end
|
|
21
19
|
|
22
20
|
Bundler::GemHelper.install_tasks
|
23
21
|
|
24
|
-
task default: [:
|
22
|
+
task default: [:spec]
|
@@ -2,14 +2,11 @@ module Repack
|
|
2
2
|
# :nodoc:
|
3
3
|
class InstallGenerator < ::Rails::Generators::Base
|
4
4
|
source_root File.expand_path("../../../../example", __FILE__)
|
5
|
-
|
6
5
|
desc "Install everything you need for a basic webpack-rails integration"
|
7
6
|
class_option :router, type: :boolean, default: false, description: 'Add React Router'
|
8
7
|
class_option :redux, type: :boolean, default: false, description: 'Add Redux'
|
9
|
-
|
10
8
|
def copy_package_json
|
11
9
|
copy_file "package.json", "package.json"
|
12
|
-
|
13
10
|
if options[:router]
|
14
11
|
insert_into_file './package.json', after: /dependencies\": {\n/ do
|
15
12
|
<<-'RUBY'
|
@@ -17,7 +14,6 @@ module Repack
|
|
17
14
|
RUBY
|
18
15
|
end
|
19
16
|
end
|
20
|
-
|
21
17
|
if options[:redux]
|
22
18
|
insert_into_file './package.json', after: /dependencies\": {\n/ do
|
23
19
|
<<-'RUBY'
|
@@ -27,7 +23,6 @@ module Repack
|
|
27
23
|
RUBY
|
28
24
|
end
|
29
25
|
end
|
30
|
-
|
31
26
|
if options[:router] && options[:redux]
|
32
27
|
insert_into_file './package.json', after: /dependencies\": {\n/ do
|
33
28
|
<<-'RUBY'
|
@@ -36,17 +31,14 @@ module Repack
|
|
36
31
|
end
|
37
32
|
end
|
38
33
|
end
|
39
|
-
|
40
34
|
def copy_webpack_conf
|
41
35
|
copy_file "webpack.config.js", "config/webpack.config.js"
|
42
36
|
copy_file "webpack.config.heroku.js", "config/webpack.config.heroku.js"
|
43
37
|
end
|
44
|
-
|
45
38
|
def create_webpack_application_js
|
46
39
|
empty_directory "client"
|
47
40
|
empty_directory "client/containers"
|
48
41
|
empty_directory "client/components"
|
49
|
-
|
50
42
|
if options[:router] && options[:redux]
|
51
43
|
copy_file "boilerplate/router_redux/application.js", "client/application.js"
|
52
44
|
copy_file "boilerplate/routes.js", "client/routes.js"
|
@@ -70,9 +62,7 @@ module Repack
|
|
70
62
|
copy_file "boilerplate/application.js", "client/application.js"
|
71
63
|
copy_file "boilerplate/App.js", "client/containers/App.js"
|
72
64
|
end
|
73
|
-
|
74
65
|
application_view = 'app/views/layouts/application.html.erb'
|
75
|
-
|
76
66
|
if File.exists? application_view
|
77
67
|
insert_into_file 'app/views/layouts/application.html.erb', before: /<\/body>/ do
|
78
68
|
<<-'RUBY'
|
@@ -90,7 +80,6 @@ module Repack
|
|
90
80
|
puts "\n\n***WARNING*** HAML NOT SUPPORTED IN applictaion.html additional steps required\n\n"
|
91
81
|
end
|
92
82
|
end
|
93
|
-
|
94
83
|
def add_to_gitignore
|
95
84
|
append_to_file ".gitignore" do
|
96
85
|
<<-EOF.strip_heredoc
|
@@ -100,17 +89,13 @@ module Repack
|
|
100
89
|
EOF
|
101
90
|
end
|
102
91
|
end
|
103
|
-
|
104
92
|
def run_npm_install
|
105
93
|
run "npm install" if yes?("Would you like us to run 'npm install' for you?")
|
106
94
|
end
|
107
|
-
|
108
95
|
def whats_next
|
109
96
|
puts <<-EOF.strip_heredoc
|
110
|
-
|
111
97
|
We've set up the basics of repack for you, but you'll still
|
112
98
|
need to:
|
113
|
-
|
114
99
|
1. Add an element with an id of 'app' to your layout
|
115
100
|
2. To disable hot module replacement remove <script src="http://localhost:3808/webpack-dev-server.js"></script> from layout
|
116
101
|
3. Run 'npm run dev_server' to run the webpack-dev-server
|
@@ -119,18 +104,14 @@ module Repack
|
|
119
104
|
get '*unmatched_route', to: <your client controller>#<default action>
|
120
105
|
This must be the very last route in your routes.rb file
|
121
106
|
e.g. get '*unmatched_route', to: 'home#index'
|
122
|
-
|
123
107
|
FOR HEROKU DEPLOYS:
|
124
108
|
1. npm run heroku-setup
|
125
109
|
2. Push to heroku the post-build hook will take care of the rest
|
126
|
-
|
127
110
|
See the README.md for this gem at
|
128
111
|
https://github.com/cottonwoodcoding/repack/blob/master/README.md
|
129
112
|
for more info.
|
130
|
-
|
131
113
|
Thanks for using repack!
|
132
|
-
|
133
114
|
EOF
|
134
115
|
end
|
135
116
|
end
|
136
|
-
end
|
117
|
+
end
|
@@ -37,9 +37,15 @@ module Repack
|
|
37
37
|
def create_rails_view
|
38
38
|
name = @view.downcase.gsub(/ /, '_')
|
39
39
|
empty_directory "app/views/#{name.pluralize}"
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
if Gem.loaded_specs.has_key? 'haml-rails'
|
41
|
+
file = "app/views/#{name.pluralize}/index.html.haml"
|
42
|
+
copy_file "boilerplate/views/rails_view.html.haml", file
|
43
|
+
gsub_file file, /placeholder/, name
|
44
|
+
else
|
45
|
+
file = "app/views/#{name.pluralize}/index.html.erb"
|
46
|
+
copy_file "boilerplate/views/rails_view.html.erb", file
|
47
|
+
gsub_file file, /placeholder/, name
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
data/lib/repack.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require '
|
1
|
+
require 'repack/rails'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
require 'repack/manifest'
|
3
|
+
|
4
|
+
module Repack
|
5
|
+
# Asset path helpers for use with webpack
|
6
|
+
module Helper
|
7
|
+
# Return asset paths for a particular webpack entry point.
|
8
|
+
#
|
9
|
+
# Response may either be full URLs (eg http://localhost/...) if the dev server
|
10
|
+
# is in use or a host-relative URl (eg /webpack/...) if assets are precompiled.
|
11
|
+
#
|
12
|
+
# Will raise an error if our manifest can't be found or the entry point does
|
13
|
+
# not exist.
|
14
|
+
def webpack_asset_paths(source, extension: nil)
|
15
|
+
return "" unless source.present?
|
16
|
+
|
17
|
+
paths = Repack::Manifest.asset_paths(source)
|
18
|
+
paths = paths.select {|p| p.ends_with? ".#{extension}" } if extension
|
19
|
+
|
20
|
+
host = ::Rails.configuration.repack.dev_server.host
|
21
|
+
port = ::Rails.configuration.repack.dev_server.port
|
22
|
+
|
23
|
+
if ::Rails.configuration.repack.dev_server.enabled
|
24
|
+
paths.map! do |p|
|
25
|
+
"//#{host}:#{port}#{p}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
paths
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Repack
|
5
|
+
# Webpack manifest loading, caching & entry point retrieval
|
6
|
+
class Manifest
|
7
|
+
# Raised if we can't read our webpack manifest for whatever reason
|
8
|
+
class ManifestLoadError < StandardError
|
9
|
+
def initialize(message, orig)
|
10
|
+
super "#{message} (original error #{orig})"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Raised if a supplied entry point does not exist in the webpack manifest
|
15
|
+
class EntryPointMissingError < StandardError
|
16
|
+
end
|
17
|
+
|
18
|
+
class << self
|
19
|
+
# :nodoc:
|
20
|
+
def asset_paths(source)
|
21
|
+
paths = manifest["assetsByChunkName"][source]
|
22
|
+
if paths
|
23
|
+
# Can be either a string or an array of strings.
|
24
|
+
# Do not include source maps as they are not javascript
|
25
|
+
[paths].flatten.reject { |p| p =~ /.*\.map$/ }.map do |p|
|
26
|
+
"/#{::Rails.configuration.repack.public_path}/#{p}"
|
27
|
+
end
|
28
|
+
else
|
29
|
+
raise EntryPointMissingError, "Can't find entry point '#{source}' in webpack manifest"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def manifest
|
36
|
+
if ::Rails.configuration.repack.dev_server.enabled
|
37
|
+
# Don't cache if we're in dev server mode, manifest may change ...
|
38
|
+
load_manifest
|
39
|
+
else
|
40
|
+
# ... otherwise cache at class level, as JSON loading/parsing can be expensive
|
41
|
+
@manifest ||= load_manifest
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_manifest
|
46
|
+
data = if ::Rails.configuration.repack.dev_server.enabled
|
47
|
+
load_dev_server_manifest
|
48
|
+
else
|
49
|
+
load_static_manifest
|
50
|
+
end
|
51
|
+
JSON.parse(data)
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_dev_server_manifest
|
55
|
+
http = Net::HTTP.new(
|
56
|
+
"localhost",
|
57
|
+
::Rails.configuration.repack.dev_server.port)
|
58
|
+
http.use_ssl = ::Rails.configuration.repack.dev_server.https
|
59
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
60
|
+
http.get(dev_server_path).body
|
61
|
+
rescue => e
|
62
|
+
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)
|
63
|
+
end
|
64
|
+
|
65
|
+
def load_static_manifest
|
66
|
+
File.read(static_manifest_path)
|
67
|
+
rescue => e
|
68
|
+
raise ManifestLoadError.new("Could not load compiled manifest from #{static_manifest_path} - have you run `rake webpack:compile`?", e)
|
69
|
+
end
|
70
|
+
|
71
|
+
def static_manifest_path
|
72
|
+
::Rails.root.join(
|
73
|
+
::Rails.configuration.repack.output_dir,
|
74
|
+
::Rails.configuration.repack.manifest_filename
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
def dev_server_path
|
79
|
+
"/#{::Rails.configuration.repack.public_path}/#{::Rails.configuration.repack.manifest_filename}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def dev_server_url
|
83
|
+
"http://localhost:#{::Rails.configuration.repack.dev_server.port}#{dev_server_path}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/repack/rails.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'rails/railtie'
|
3
|
+
require 'repack/helper'
|
4
|
+
|
5
|
+
module Repack
|
6
|
+
# :nodoc:
|
7
|
+
class Railtie < ::Rails::Railtie
|
8
|
+
config.after_initialize do
|
9
|
+
ActiveSupport.on_load(:action_view) do
|
10
|
+
include Repack::Helper
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
config.repack = ActiveSupport::OrderedOptions.new
|
15
|
+
config.repack.config_file = 'config/repack.config.js'
|
16
|
+
config.repack.binary = 'node_modules/.bin/repack'
|
17
|
+
|
18
|
+
config.repack.dev_server = ActiveSupport::OrderedOptions.new
|
19
|
+
config.repack.dev_server.host = 'localhost'
|
20
|
+
config.repack.dev_server.port = 3808
|
21
|
+
config.repack.dev_server.https = false # note - this will use OpenSSL::SSL::VERIFY_NONE
|
22
|
+
config.repack.dev_server.binary = 'node_modules/.bin/repack-dev-server'
|
23
|
+
config.repack.dev_server.enabled = !::Rails.env.production?
|
24
|
+
|
25
|
+
config.repack.output_dir = "public/client"
|
26
|
+
config.repack.public_path = "client"
|
27
|
+
config.repack.manifest_filename = "manifest.json"
|
28
|
+
|
29
|
+
rake_tasks do
|
30
|
+
load "tasks/webpack.rake"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Jungst
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- example/boilerplate/views/ContainerTemplate.js
|
54
54
|
- example/boilerplate/views/ViewTemplate.js
|
55
55
|
- example/boilerplate/views/rails_view.html.erb
|
56
|
+
- example/boilerplate/views/rails_view.html.haml
|
56
57
|
- example/dot_gitignore
|
57
58
|
- example/package.json
|
58
59
|
- example/webpack.config.heroku.js
|
@@ -60,12 +61,12 @@ files:
|
|
60
61
|
- lib/generators/repack/install_generator.rb
|
61
62
|
- lib/generators/repack/view_generator.rb
|
62
63
|
- lib/repack.rb
|
64
|
+
- lib/repack/helper.rb
|
65
|
+
- lib/repack/manifest.rb
|
66
|
+
- lib/repack/rails.rb
|
67
|
+
- lib/repack/railtie.rb
|
68
|
+
- lib/repack/version.rb
|
63
69
|
- lib/tasks/webpack.rake
|
64
|
-
- lib/webpack/rails.rb
|
65
|
-
- lib/webpack/rails/react/helper.rb
|
66
|
-
- lib/webpack/rails/react/manifest.rb
|
67
|
-
- lib/webpack/rails/react/version.rb
|
68
|
-
- lib/webpack/railtie.rb
|
69
70
|
homepage: https://github.com/cottonwoodcoding/reapack
|
70
71
|
licenses:
|
71
72
|
- MIT
|
data/lib/webpack/rails.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'action_view'
|
2
|
-
require 'webpack/rails/react/manifest'
|
3
|
-
|
4
|
-
module Webpack
|
5
|
-
module Rails
|
6
|
-
module React
|
7
|
-
# Asset path helpers for use with webpack
|
8
|
-
module Helper
|
9
|
-
# Return asset paths for a particular webpack entry point.
|
10
|
-
#
|
11
|
-
# Response may either be full URLs (eg http://localhost/...) if the dev server
|
12
|
-
# is in use or a host-relative URl (eg /webpack/...) if assets are precompiled.
|
13
|
-
#
|
14
|
-
# Will raise an error if our manifest can't be found or the entry point does
|
15
|
-
# not exist.
|
16
|
-
def webpack_asset_paths(source, extension: nil)
|
17
|
-
return "" unless source.present?
|
18
|
-
|
19
|
-
paths = Webpack::Rails::React::Manifest.asset_paths(source)
|
20
|
-
paths = paths.select {|p| p.ends_with? ".#{extension}" } if extension
|
21
|
-
|
22
|
-
host = ::Rails.configuration.webpack.dev_server.host
|
23
|
-
port = ::Rails.configuration.webpack.dev_server.port
|
24
|
-
|
25
|
-
if ::Rails.configuration.webpack.dev_server.enabled
|
26
|
-
paths.map! do |p|
|
27
|
-
"//#{host}:#{port}#{p}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
paths
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'uri'
|
3
|
-
|
4
|
-
module Webpack
|
5
|
-
module Rails
|
6
|
-
module React
|
7
|
-
# Webpack manifest loading, caching & entry point retrieval
|
8
|
-
class Manifest
|
9
|
-
# Raised if we can't read our webpack manifest for whatever reason
|
10
|
-
class ManifestLoadError < StandardError
|
11
|
-
def initialize(message, orig)
|
12
|
-
super "#{message} (original error #{orig})"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Raised if a supplied entry point does not exist in the webpack manifest
|
17
|
-
class EntryPointMissingError < StandardError
|
18
|
-
end
|
19
|
-
|
20
|
-
class << self
|
21
|
-
# :nodoc:
|
22
|
-
def asset_paths(source)
|
23
|
-
paths = manifest["assetsByChunkName"][source]
|
24
|
-
if paths
|
25
|
-
# Can be either a string or an array of strings.
|
26
|
-
# Do not include source maps as they are not javascript
|
27
|
-
[paths].flatten.reject { |p| p =~ /.*\.map$/ }.map do |p|
|
28
|
-
"/#{::Rails.configuration.webpack.public_path}/#{p}"
|
29
|
-
end
|
30
|
-
else
|
31
|
-
raise EntryPointMissingError, "Can't find entry point '#{source}' in webpack manifest"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def manifest
|
38
|
-
if ::Rails.configuration.webpack.dev_server.enabled
|
39
|
-
# Don't cache if we're in dev server mode, manifest may change ...
|
40
|
-
load_manifest
|
41
|
-
else
|
42
|
-
# ... otherwise cache at class level, as JSON loading/parsing can be expensive
|
43
|
-
@manifest ||= load_manifest
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def load_manifest
|
48
|
-
data = if ::Rails.configuration.webpack.dev_server.enabled
|
49
|
-
load_dev_server_manifest
|
50
|
-
else
|
51
|
-
load_static_manifest
|
52
|
-
end
|
53
|
-
JSON.parse(data)
|
54
|
-
end
|
55
|
-
|
56
|
-
def load_dev_server_manifest
|
57
|
-
http = Net::HTTP.new(
|
58
|
-
"localhost",
|
59
|
-
::Rails.configuration.webpack.dev_server.port)
|
60
|
-
http.use_ssl = ::Rails.configuration.webpack.dev_server.https
|
61
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
62
|
-
http.get(dev_server_path).body
|
63
|
-
rescue => e
|
64
|
-
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)
|
65
|
-
end
|
66
|
-
|
67
|
-
def load_static_manifest
|
68
|
-
File.read(static_manifest_path)
|
69
|
-
rescue => e
|
70
|
-
raise ManifestLoadError.new("Could not load compiled manifest from #{static_manifest_path} - have you run `rake webpack:compile`?", e)
|
71
|
-
end
|
72
|
-
|
73
|
-
def static_manifest_path
|
74
|
-
::Rails.root.join(
|
75
|
-
::Rails.configuration.webpack.output_dir,
|
76
|
-
::Rails.configuration.webpack.manifest_filename
|
77
|
-
)
|
78
|
-
end
|
79
|
-
|
80
|
-
def dev_server_path
|
81
|
-
"/#{::Rails.configuration.webpack.public_path}/#{::Rails.configuration.webpack.manifest_filename}"
|
82
|
-
end
|
83
|
-
|
84
|
-
def dev_server_url
|
85
|
-
"http://localhost:#{::Rails.configuration.webpack.dev_server.port}#{dev_server_path}"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
data/lib/webpack/railtie.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'rails'
|
2
|
-
require 'rails/railtie'
|
3
|
-
require 'webpack/rails/react/helper'
|
4
|
-
|
5
|
-
module Webpack
|
6
|
-
# :nodoc:
|
7
|
-
class Railtie < ::Rails::Railtie
|
8
|
-
config.after_initialize do
|
9
|
-
ActiveSupport.on_load(:action_view) do
|
10
|
-
include Webpack::Rails::React::Helper
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
config.webpack = ActiveSupport::OrderedOptions.new
|
15
|
-
config.webpack.config_file = 'config/webpack.config.js'
|
16
|
-
config.webpack.binary = 'node_modules/.bin/webpack'
|
17
|
-
|
18
|
-
config.webpack.dev_server = ActiveSupport::OrderedOptions.new
|
19
|
-
config.webpack.dev_server.host = 'localhost'
|
20
|
-
config.webpack.dev_server.port = 3808
|
21
|
-
config.webpack.dev_server.https = false # note - this will use OpenSSL::SSL::VERIFY_NONE
|
22
|
-
config.webpack.dev_server.binary = 'node_modules/.bin/webpack-dev-server'
|
23
|
-
config.webpack.dev_server.enabled = !::Rails.env.production?
|
24
|
-
|
25
|
-
config.webpack.output_dir = "public/client"
|
26
|
-
config.webpack.public_path = "client"
|
27
|
-
config.webpack.manifest_filename = "manifest.json"
|
28
|
-
|
29
|
-
rake_tasks do
|
30
|
-
load "tasks/webpack.rake"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|