Skip to content

Commit

Permalink
Update to 8.0.0 beta.2 using WebpackerLite
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizencodes authored and justin808 committed May 11, 2017
1 parent 9c24b98 commit a2e2a92
Show file tree
Hide file tree
Showing 18 changed files with 259 additions and 273 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ gem "sdoc", group: :doc
# Use Rails Html Sanitizer for HTML sanitization
gem "rails-html-sanitizer"

gem "react_on_rails", "7.0.0"
gem "react_on_rails", "8.0.0.beta.2"

gem "webpacker_lite", "0.0.4"
gem "webpacker_lite", "1.0.0"

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# mini_racer is probably faster than therubyracer
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ GEM
rb-inotify (0.9.8)
ffi (>= 0.5.0)
rdoc (4.3.0)
react_on_rails (7.0.0)
react_on_rails (8.0.0.beta.2)
addressable
connection_pool
execjs (~> 2.5)
Expand Down Expand Up @@ -288,7 +288,7 @@ GEM
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webpacker_lite (0.0.4)
webpacker_lite (1.0.0)
activesupport (>= 4.2)
multi_json (~> 1.2)
railties (>= 4.2)
Expand Down Expand Up @@ -334,7 +334,7 @@ DEPENDENCIES
rails
rails-html-sanitizer
rainbow
react_on_rails (= 7.0.0)
react_on_rails (= 8.0.0.beta.2)
redis
rspec-rails (~> 3)
rspec-retry
Expand All @@ -348,7 +348,7 @@ DEPENDENCIES
spring-commands-rspec
uglifier
web-console
webpacker_lite (= 0.0.4)
webpacker_lite (= 1.0.0)

RUBY VERSION
ruby 2.4.1p111
Expand Down
2 changes: 1 addition & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0

# Run the hot reload server for client development
hot-assets: sh -c 'rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 yarn run hot-assets'
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'

# Render static client assets
rails-static-client-assets: sh -c 'yarn run build:dev:client'
Expand Down
2 changes: 1 addition & 1 deletion Procfile.hot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0

# Run the hot reload server for client development
hot-assets: sh -c 'rm public/webpack/* || true && bundle exec rake react_on_rails:locale && HOT_RAILS_PORT=3500 yarn run hot-assets'
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'

# Keep the JS fresh for server rendering. Remove if not server rendering
rails-server-assets: sh -c 'yarn run build:dev:server'
2 changes: 1 addition & 1 deletion Procfile.static
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
rails: REACT_ON_RAILS_ENV= rails s -b 0.0.0.0

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

# Build server assets, watching for changes. Remove if not server rendering.
rails-server-assets: yarn run build:dev:server
11 changes: 5 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
<head>
<title>RailsReactTutorial</title>

<%= javascript_pack_tag 'vendor' %>
<%= javascript_pack_tag 'app' %>

<!-- These do not use turbolinks, so no data-turbolinks-track -->
<!-- This is to load the hot assets. -->

<%= stylesheet_pack_tag(static: ['vendor-bundle', 'app-bundle'],
media: 'all',
'data-turbolinks-track': true) %>

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

<%= csrf_meta_tags %>
</head>
Expand Down
7 changes: 4 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
"immutable": "^3.8.1",
"imports-loader": "^0.7.1",
"intl": "^1.2.5",
"js-yaml": "^3.8.2",
"jquery": "^3.2.1",
"jquery-ujs": "^1.2.2",
"js-yaml": "^3.8.2",
"loader-utils": "^1.1.0",
"lodash": "^4.17.4",
"marked": "^0.3.6",
Expand All @@ -82,7 +82,7 @@
"react-bootstrap": "^0.30.8",
"react-dom": "^15.4.1",
"react-intl": "^2.2.2",
"react-on-rails": "^7.0.0",
"react-on-rails": "8.0.0-beta.2",
"react-redux": "^4.4.6",
"react-router": "^3.0.0",
"react-router-redux": "^4.0.7",
Expand All @@ -95,7 +95,8 @@
"turbolinks": "^5.0.0",
"url-loader": "^0.5.8",
"webpack": "^2.3.3",
"webpack-manifest-plugin": "^1.1.0"
"webpack-manifest-plugin": "^1.1.0",
"webpack-merge": "^4.1.0"
},
"devDependencies": {
"babel-eslint": "^7.2.1",
Expand Down
8 changes: 7 additions & 1 deletion client/server-rails-hot.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
/* eslint no-var: 0, no-console: 0, import/no-extraneous-dependencies: 0 */

import webpack from 'webpack';

import WebpackDevServer from 'webpack-dev-server';

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

const { devServer: devServerConfig, publicPath } = require('./webpackConfigLoader.js');
const { resolve } = require('path');

const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');

const configPath = resolve('..', 'config', 'webpack');
const { devServer: devServerConfig, publicPath } = webpackConfigLoader(configPath);

const compiler = webpack(webpackConfig);

Expand Down
25 changes: 13 additions & 12 deletions client/webpack.client.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

// Common client-side webpack configuration used by webpack.hot.config and webpack.rails.config.
const webpack = require('webpack');

const { resolve } = require('path');

const ManifestPlugin = require('webpack-manifest-plugin');
const { paths, publicPath } = require('./webpackConfigLoader.js');

const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');

const configPath = resolve('..', 'config', 'webpack');
const { paths, publicPath } = webpackConfigLoader(configPath);

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

// See use of 'vendor' in the CommonsChunkPlugin inclusion below.
vendor: [
'vendor-bundle': [
'babel-polyfill',
'es5-shim/es5-shim',
'es5-shim/es5-sham',
Expand All @@ -44,29 +49,25 @@ module.exports = {
],

// This will contain the app entry points defined by webpack.hot.config and webpack.rails.config
app: [
'app-bundle': [
'./app/bundles/comments/startup/clientRegistration',
],
},

output: {
filename: '[name]-bundle.js',
filename: '[name].js',
path: resolve('..', paths.output, paths.assets),
pathinfo: true,
},

resolve: {
extensions: paths.extensions,
extensions: ['.js', '.jsx'],
modules: [
paths.source,
paths.node_modules,
'client/app',
'client/node_modules',
],
},

resolveLoader: {
modules: [paths.node_modules],
},

plugins: [
new webpack.DefinePlugin({
'process.env': {
Expand All @@ -79,7 +80,7 @@ module.exports = {
new webpack.optimize.CommonsChunkPlugin({

// This name 'vendor' ties into the entry definition
name: 'vendor',
name: 'vendor-bundle',

// We don't want the default vendor.js name
filename: 'vendor-bundle.js',
Expand Down
Loading

0 comments on commit a2e2a92

Please sign in to comment.