webpack-rails-react 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/example/boilerplate/views/ContainerTemplate.js +8 -0
- data/example/boilerplate/views/ViewTemplate.js +8 -0
- data/example/boilerplate/views/rails_view.html.erb +5 -0
- data/example/package.json +4 -0
- data/lib/generators/webpack_rails_react/install_generator.rb +20 -29
- data/lib/generators/webpack_rails_react/view_generator.rb +45 -0
- data/lib/webpack/rails/react/helper.rb +1 -1
- data/lib/webpack/rails/react/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0666af5c95adea9310b4b46f5a79fb08ab91c89f
|
4
|
+
data.tar.gz: c7a947c1895d8df2d6e03b5ae1a54f4cf03e07a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3df17e31cd4c474108d35037d4c8ee68d81ec7cfce060d8e8e0643ede832cda05b6c12971d2f491b75a152989ae715ab445b04eacdabe0c954908917fd42d388
|
7
|
+
data.tar.gz: 77c527eab7a0c5ccbac5043fdb039d6b60e2a8b6688bbf12c0c34b33a5eab5ace67ec1b732d7c1b20bcc641f0401ae9d13e1f80fee86c15d41c40d4b5e6679fd
|
data/README.md
CHANGED
@@ -101,6 +101,15 @@ If you're using `[chunkhash]` in your build asset filenames (which you should be
|
|
101
101
|
* Add eslint to client
|
102
102
|
* Integration tests
|
103
103
|
|
104
|
+
|
105
|
+
## Experimental
|
106
|
+
A view generator has been added.
|
107
|
+
|
108
|
+
1.Generate a controller
|
109
|
+
2.Add at least an index route for the controller
|
110
|
+
3.rails g webpack_rails_react:view name_of_view (should be singular and match controller)
|
111
|
+
|
112
|
+
|
104
113
|
## Contributing
|
105
114
|
|
106
115
|
Pull requests & issues welcome. Advice & criticism regarding webpack config approach also welcome.
|
data/example/package.json
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
"name": "webpack-rails",
|
3
3
|
"version": "0.0.1",
|
4
4
|
"license": "MIT",
|
5
|
+
"scripts": {
|
6
|
+
"dev_server": "./node_modules/.bin/webpack-dev-server --config config/webpack.config.js",
|
7
|
+
"build": "webpack --config=config/webpack.config.js -p"
|
8
|
+
},
|
5
9
|
"dependencies": {
|
6
10
|
"react": "^15.1.0",
|
7
11
|
"react-dom": "^15.1.0",
|
@@ -7,18 +7,6 @@ module WebpackRailsReact
|
|
7
7
|
class_option :router, type: :boolean, default: false, description: 'Add React Router'
|
8
8
|
class_option :redux, type: :boolean, default: false, description: 'Add Redux'
|
9
9
|
|
10
|
-
def add_foreman_to_gemfile
|
11
|
-
gem 'foreman'
|
12
|
-
end
|
13
|
-
|
14
|
-
def copy_procfile
|
15
|
-
if File.exists? "Procfile"
|
16
|
-
append_file "Procfile", "webpack: ./node_modules/.bin/webpack-dev-server --config config/webpack.config.js"
|
17
|
-
else
|
18
|
-
copy_file "Procfile", "Procfile"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
10
|
def copy_package_json
|
23
11
|
copy_file "package.json", "package.json"
|
24
12
|
|
@@ -82,17 +70,23 @@ module WebpackRailsReact
|
|
82
70
|
copy_file "boilerplate/App.js", "webpack/containers/App.js"
|
83
71
|
end
|
84
72
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
73
|
+
application_view = 'app/views/layouts/application.html.erb'
|
74
|
+
|
75
|
+
if File.exists? application_view
|
76
|
+
insert_into_file 'app/views/layouts/application.html.erb', before: /<\/body>/ do
|
77
|
+
<<-'RUBY'
|
78
|
+
<%= ja vascript_include_tag *webpack_asset_paths('application') %>
|
79
|
+
RUBY
|
80
|
+
end
|
81
|
+
insert_into_file 'app/views/layouts/application.html.erb', before: /<\/head>/ do
|
82
|
+
<<-'RUBY'
|
83
|
+
<% if Rails.env.development? %>
|
84
|
+
<script src="http://localhost:3808/webpack-dev-server.js"></script>
|
85
|
+
<% end %>
|
86
|
+
RUBY
|
87
|
+
end
|
88
|
+
else
|
89
|
+
puts "\n\n***WARNING*** HAML NOT SUPPORTED IN applictaion.html additional steps required\n\n"
|
96
90
|
end
|
97
91
|
end
|
98
92
|
|
@@ -110,10 +104,6 @@ module WebpackRailsReact
|
|
110
104
|
run "npm install" if yes?("Would you like us to run 'npm install' for you?")
|
111
105
|
end
|
112
106
|
|
113
|
-
def run_bundle_install
|
114
|
-
run "bundle install" if yes?("Would you like us to run 'bundle install' for you?")
|
115
|
-
end
|
116
|
-
|
117
107
|
def whats_next
|
118
108
|
puts <<-EOF.strip_heredoc
|
119
109
|
|
@@ -122,8 +112,9 @@ module WebpackRailsReact
|
|
122
112
|
|
123
113
|
1. Add an element with an id of 'app' to your layout
|
124
114
|
2. To disable hot module replacement remove <script src="http://localhost:3808/webpack-dev-server.js"></script> from layout
|
125
|
-
3. Run '
|
126
|
-
4.
|
115
|
+
3. Run 'npm run dev_server' to run the webpack-dev-server
|
116
|
+
4. Run 'bundle exec rails s' to run the rails server (both servers must be running)
|
117
|
+
5. If you are using react-router and want to sync server routes add:
|
127
118
|
get '*unmatched_route', to: <your client controller>#<default action>
|
128
119
|
This must be the very last route in your routes.rb file
|
129
120
|
e.g. get '*unmatched_route', to: 'home#index'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module WebpackRailsReact
|
2
|
+
# :nodoc:
|
3
|
+
class ViewGenerator < ::Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../../../../example", __FILE__)
|
5
|
+
|
6
|
+
desc "Generate a view with webpack entry / rails view / and webpack container"
|
7
|
+
|
8
|
+
def normalize_view_name
|
9
|
+
raise "View name argument missing" if args.length == 0
|
10
|
+
@view = args[0]
|
11
|
+
end
|
12
|
+
|
13
|
+
def update_webpack_entry
|
14
|
+
name = @view.downcase.gsub(/ /, "_")
|
15
|
+
path = "'#{name}': './webpack/#{name}.js',"
|
16
|
+
insert_into_file 'config/webpack.config.js', after: /entry: {\n/ do
|
17
|
+
<<-CONFIG
|
18
|
+
#{path}
|
19
|
+
CONFIG
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_entry_file
|
24
|
+
file = "webpack/#{@view.gsub(/ /, '')}.js"
|
25
|
+
name = @view.titleize.gsub(/ /, '')
|
26
|
+
copy_file "boilerplate/views/ViewTemplate.js", file
|
27
|
+
gsub_file file, /Placeholder/, name
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_container
|
31
|
+
name = @view.titleize.gsub(/ /, '')
|
32
|
+
file = "webpack/containers/#{name}.js"
|
33
|
+
copy_file "boilerplate/views/ContainerTemplate.js", file
|
34
|
+
gsub_file file, /Placeholder/, name
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_rails_view
|
38
|
+
name = @view.downcase.gsub(/ /, '_')
|
39
|
+
empty_directory "app/views/#{name.pluralize}"
|
40
|
+
file = "app/views/#{name.pluralize}/index.html.erb"
|
41
|
+
copy_file "boilerplate/views/rails_view.html.erb", file
|
42
|
+
gsub_file file, /placeholder/, name
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpack-rails-react
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Jungst
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -50,10 +50,14 @@ files:
|
|
50
50
|
- example/boilerplate/router_redux/reducers.js
|
51
51
|
- example/boilerplate/router_redux/store.js
|
52
52
|
- example/boilerplate/routes.js
|
53
|
+
- example/boilerplate/views/ContainerTemplate.js
|
54
|
+
- example/boilerplate/views/ViewTemplate.js
|
55
|
+
- example/boilerplate/views/rails_view.html.erb
|
53
56
|
- example/dot_gitignore
|
54
57
|
- example/package.json
|
55
58
|
- example/webpack.config.js
|
56
59
|
- lib/generators/webpack_rails_react/install_generator.rb
|
60
|
+
- lib/generators/webpack_rails_react/view_generator.rb
|
57
61
|
- lib/tasks/webpack.rake
|
58
62
|
- lib/webpack-rails-react.rb
|
59
63
|
- lib/webpack/rails.rb
|
@@ -81,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
85
|
version: '0'
|
82
86
|
requirements: []
|
83
87
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.5
|
88
|
+
rubygems_version: 2.4.5
|
85
89
|
signing_key:
|
86
90
|
specification_version: 4
|
87
91
|
summary: Webpack / Rails / React
|