Skip to content

Commit a2e2a92

Browse files
kaizencodesjustin808
authored andcommitted
Update to 8.0.0 beta.2 using WebpackerLite
1 parent 9c24b98 commit a2e2a92

18 files changed

+259
-273
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ gem "sdoc", group: :doc
3838
# Use Rails Html Sanitizer for HTML sanitization
3939
gem "rails-html-sanitizer"
4040

41-
gem "react_on_rails", "7.0.0"
41+
gem "react_on_rails", "8.0.0.beta.2"
4242

43-
gem "webpacker_lite", "0.0.4"
43+
gem "webpacker_lite", "1.0.0"
4444

4545
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
4646
# mini_racer is probably faster than therubyracer

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ GEM
200200
rb-inotify (0.9.8)
201201
ffi (>= 0.5.0)
202202
rdoc (4.3.0)
203-
react_on_rails (7.0.0)
203+
react_on_rails (8.0.0.beta.2)
204204
addressable
205205
connection_pool
206206
execjs (~> 2.5)
@@ -288,7 +288,7 @@ GEM
288288
activemodel (>= 5.0)
289289
bindex (>= 0.4.0)
290290
railties (>= 5.0)
291-
webpacker_lite (0.0.4)
291+
webpacker_lite (1.0.0)
292292
activesupport (>= 4.2)
293293
multi_json (~> 1.2)
294294
railties (>= 4.2)
@@ -334,7 +334,7 @@ DEPENDENCIES
334334
rails
335335
rails-html-sanitizer
336336
rainbow
337-
react_on_rails (= 7.0.0)
337+
react_on_rails (= 8.0.0.beta.2)
338338
redis
339339
rspec-rails (~> 3)
340340
rspec-retry
@@ -348,7 +348,7 @@ DEPENDENCIES
348348
spring-commands-rspec
349349
uglifier
350350
web-console
351-
webpacker_lite (= 0.0.4)
351+
webpacker_lite (= 1.0.0)
352352

353353
RUBY VERSION
354354
ruby 2.4.1p111

Procfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0
88

99
# Run the hot reload server for client development
10-
hot-assets: sh -c 'rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 yarn run hot-assets'
10+
hot-assets: sh -c 'rm -rf public/webpack/development || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 yarn run hot-assets'
1111

1212
# Render static client assets
1313
rails-static-client-assets: sh -c 'yarn run build:dev:client'

Procfile.hot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0
77

88
# Run the hot reload server for client development
9-
hot-assets: sh -c 'rm public/webpack/* || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 yarn run hot-assets'
9+
hot-assets: sh -c 'rm -rf public/webpack/development || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 yarn run hot-assets'
1010

1111
# Keep the JS fresh for server rendering. Remove if not server rendering
1212
rails-server-assets: sh -c 'yarn run build:dev:server'

Procfile.static

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
rails: REACT_ON_RAILS_ENV= rails s -b 0.0.0.0
33

44
# Build client assets, watching for changes.
5-
rails-client-assets: rm public/webpack/* || true && bundle exec rake react_on_rails:locale && yarn run build:dev:client
5+
rails-client-assets: rm -rf public/webpack/development || true && bundle exec rake react_on_rails:locale && yarn run build:dev:client
66

77
# Build server assets, watching for changes. Remove if not server rendering.
88
rails-server-assets: yarn run build:dev:server

app/views/layouts/application.html.erb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
<head>
44
<title>RailsReactTutorial</title>
55

6-
<%= javascript_pack_tag 'vendor' %>
7-
<%= javascript_pack_tag 'app' %>
8-
9-
<!-- These do not use turbolinks, so no data-turbolinks-track -->
10-
<!-- This is to load the hot assets. -->
11-
6+
<%= stylesheet_pack_tag(static: ['vendor-bundle', 'app-bundle'],
7+
media: 'all',
8+
'data-turbolinks-track': true) %>
129

10+
<%= javascript_pack_tag('vendor-bundle', 'data-turbolinks-track': true) %>
11+
<%= javascript_pack_tag('app-bundle', 'data-turbolinks-track': true) %>
1312

1413
<%= csrf_meta_tags %>
1514
</head>

client/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
"immutable": "^3.8.1",
6969
"imports-loader": "^0.7.1",
7070
"intl": "^1.2.5",
71-
"js-yaml": "^3.8.2",
7271
"jquery": "^3.2.1",
7372
"jquery-ujs": "^1.2.2",
73+
"js-yaml": "^3.8.2",
7474
"loader-utils": "^1.1.0",
7575
"lodash": "^4.17.4",
7676
"marked": "^0.3.6",
@@ -82,7 +82,7 @@
8282
"react-bootstrap": "^0.30.8",
8383
"react-dom": "^15.4.1",
8484
"react-intl": "^2.2.2",
85-
"react-on-rails": "^7.0.0",
85+
"react-on-rails": "8.0.0-beta.2",
8686
"react-redux": "^4.4.6",
8787
"react-router": "^3.0.0",
8888
"react-router-redux": "^4.0.7",
@@ -95,7 +95,8 @@
9595
"turbolinks": "^5.0.0",
9696
"url-loader": "^0.5.8",
9797
"webpack": "^2.3.3",
98-
"webpack-manifest-plugin": "^1.1.0"
98+
"webpack-manifest-plugin": "^1.1.0",
99+
"webpack-merge": "^4.1.0"
99100
},
100101
"devDependencies": {
101102
"babel-eslint": "^7.2.1",

client/server-rails-hot.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
/* eslint no-var: 0, no-console: 0, import/no-extraneous-dependencies: 0 */
22

33
import webpack from 'webpack';
4+
45
import WebpackDevServer from 'webpack-dev-server';
56

67
import webpackConfig from './webpack.client.rails.hot.config';
78

8-
const { devServer: devServerConfig, publicPath } = require('./webpackConfigLoader.js');
9+
const { resolve } = require('path');
10+
11+
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
12+
13+
const configPath = resolve('..', 'config', 'webpack');
14+
const { devServer: devServerConfig, publicPath } = webpackConfigLoader(configPath);
915

1016
const compiler = webpack(webpackConfig);
1117

client/webpack.client.base.config.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33

44
// Common client-side webpack configuration used by webpack.hot.config and webpack.rails.config.
55
const webpack = require('webpack');
6+
67
const { resolve } = require('path');
78

89
const ManifestPlugin = require('webpack-manifest-plugin');
9-
const { paths, publicPath } = require('./webpackConfigLoader.js');
10+
11+
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
12+
13+
const configPath = resolve('..', 'config', 'webpack');
14+
const { paths, publicPath } = webpackConfigLoader(configPath);
1015

1116
const devBuild = process.env.NODE_ENV !== 'production';
1217
const nodeEnv = devBuild ? 'development' : 'production';
@@ -18,7 +23,7 @@ module.exports = {
1823
entry: {
1924

2025
// See use of 'vendor' in the CommonsChunkPlugin inclusion below.
21-
vendor: [
26+
'vendor-bundle': [
2227
'babel-polyfill',
2328
'es5-shim/es5-shim',
2429
'es5-shim/es5-sham',
@@ -44,29 +49,25 @@ module.exports = {
4449
],
4550

4651
// This will contain the app entry points defined by webpack.hot.config and webpack.rails.config
47-
app: [
52+
'app-bundle': [
4853
'./app/bundles/comments/startup/clientRegistration',
4954
],
5055
},
5156

5257
output: {
53-
filename: '[name]-bundle.js',
58+
filename: '[name].js',
5459
path: resolve('..', paths.output, paths.assets),
5560
pathinfo: true,
5661
},
5762

5863
resolve: {
59-
extensions: paths.extensions,
64+
extensions: ['.js', '.jsx'],
6065
modules: [
61-
paths.source,
62-
paths.node_modules,
66+
'client/app',
67+
'client/node_modules',
6368
],
6469
},
6570

66-
resolveLoader: {
67-
modules: [paths.node_modules],
68-
},
69-
7071
plugins: [
7172
new webpack.DefinePlugin({
7273
'process.env': {
@@ -79,7 +80,7 @@ module.exports = {
7980
new webpack.optimize.CommonsChunkPlugin({
8081

8182
// This name 'vendor' ties into the entry definition
82-
name: 'vendor',
83+
name: 'vendor-bundle',
8384

8485
// We don't want the default vendor.js name
8586
filename: 'vendor-bundle.js',

0 commit comments

Comments
 (0)