From d7ac6b04e1a16e94a8c0bffc92c7c970c155608d Mon Sep 17 00:00:00 2001 From: YOUR NAME Date: Wed, 18 Apr 2018 17:33:02 +1000 Subject: [PATCH] older gem as possible solution --- Gemfile | 2 - Procfile.dev | 7 --- Procfile.dev-server | 12 ----- app/controllers/hello_world_controller.rb | 9 ---- .../HelloWorld/components/HelloWorld.jsx | 45 ------------------- app/javascript/packs/hello-world-bundle.js | 8 ---- app/views/hello_world/index.html.erb | 2 - app/views/layouts/hello_world.html.erb | 12 ----- config/initializers/react_on_rails.rb | 41 ----------------- config/routes.rb | 1 - 10 files changed, 139 deletions(-) delete mode 100644 Procfile.dev delete mode 100644 Procfile.dev-server delete mode 100644 app/controllers/hello_world_controller.rb delete mode 100644 app/javascript/bundles/HelloWorld/components/HelloWorld.jsx delete mode 100644 app/javascript/packs/hello-world-bundle.js delete mode 100644 app/views/hello_world/index.html.erb delete mode 100644 app/views/layouts/hello_world.html.erb delete mode 100644 config/initializers/react_on_rails.rb diff --git a/Gemfile b/Gemfile index bbe2886..14c3625 100644 --- a/Gemfile +++ b/Gemfile @@ -64,5 +64,3 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] - -gem 'mini_racer', platforms: :ruby \ No newline at end of file diff --git a/Procfile.dev b/Procfile.dev deleted file mode 100644 index 9e7f6b3..0000000 --- a/Procfile.dev +++ /dev/null @@ -1,7 +0,0 @@ -# You can run these commands in separate shells -web: rails s -p 3000 - -# Next line runs a watch process with webpack to compile the changed files. -# When making frequent changes to client side assets, you will prefer building webpack assets -# upon saving rather than when you refresh your browser page. -client: sh -c 'rm -rf public/packs/* || true && bundle exec rake react_on_rails:locale && bin/webpack -w' diff --git a/Procfile.dev-server b/Procfile.dev-server deleted file mode 100644 index 602fb49..0000000 --- a/Procfile.dev-server +++ /dev/null @@ -1,12 +0,0 @@ -# You can run these commands in separate shells instead of using foreman -web: rails s -p 3000 - -# Next line runs the webpack-dev-server -# You can edit config/webpacker.yml to set HMR to true to see hot reloading. -# Note, hot and live reloading don't work with the default generator setup on top of -# the rails/webpacker Webpack config with server rendering. -# If you have server rendering enabled, modify the call to bin/webpack-dev-server line -# so you add `--inline=false` and then CSS is not inlined. -# Otherwise, you will have an error. If you want HMR and Server Rendering, see -# the example in the https://github.com/shakacode/react-webpack-rails-tutorial -client: sh -c 'rm -rf public/packs/* || true && bundle exec rake react_on_rails:locale && bin/webpack-dev-server' diff --git a/app/controllers/hello_world_controller.rb b/app/controllers/hello_world_controller.rb deleted file mode 100644 index ad09c5e..0000000 --- a/app/controllers/hello_world_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class HelloWorldController < ApplicationController - layout "hello_world" - - def index - @hello_world_props = { name: "Stranger" } - end -end diff --git a/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx b/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx deleted file mode 100644 index ccdff82..0000000 --- a/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +++ /dev/null @@ -1,45 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; - -export default class HelloWorld extends React.Component { - static propTypes = { - name: PropTypes.string.isRequired, // this is passed from the Rails view - }; - - /** - * @param props - Comes from your rails view. - */ - constructor(props) { - super(props); - - // How to set initial state in ES6 class syntax - // https://reactjs.org/docs/state-and-lifecycle.html#adding-local-state-to-a-class - this.state = { name: this.props.name }; - } - - updateName = (name) => { - this.setState({ name }); - }; - - render() { - return ( -
-

- Hello, {this.state.name}! -

-
-
- - this.updateName(e.target.value)} - /> -
-
- ); - } -} diff --git a/app/javascript/packs/hello-world-bundle.js b/app/javascript/packs/hello-world-bundle.js deleted file mode 100644 index 9b80e86..0000000 --- a/app/javascript/packs/hello-world-bundle.js +++ /dev/null @@ -1,8 +0,0 @@ -import ReactOnRails from 'react-on-rails'; - -import HelloWorld from '../bundles/HelloWorld/components/HelloWorld'; - -// This is how react_on_rails can see the HelloWorld in the browser. -ReactOnRails.register({ - HelloWorld, -}); diff --git a/app/views/hello_world/index.html.erb b/app/views/hello_world/index.html.erb deleted file mode 100644 index 396d0a5..0000000 --- a/app/views/hello_world/index.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Hello World

-<%= react_component("HelloWorld", props: @hello_world_props, prerender: false) %> diff --git a/app/views/layouts/hello_world.html.erb b/app/views/layouts/hello_world.html.erb deleted file mode 100644 index d9c08f9..0000000 --- a/app/views/layouts/hello_world.html.erb +++ /dev/null @@ -1,12 +0,0 @@ - - - - ReactOnRailsWithWebpacker - <%= csrf_meta_tags %> - <%= javascript_pack_tag 'hello-world-bundle' %> - - - - <%= yield %> - - diff --git a/config/initializers/react_on_rails.rb b/config/initializers/react_on_rails.rb deleted file mode 100644 index d81b6f7..0000000 --- a/config/initializers/react_on_rails.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -# See docs/basics/configuration.md for many more options - -ReactOnRails.configure do |config| - # This configures the script to run to build the production assets by webpack. Set this to nil - # if you don't want react_on_rails building this file for you. - config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/webpack" - - ################################################################################ - ################################################################################ - # TEST CONFIGURATION OPTIONS - # Below options are used with the use of this test helper: - # ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config) - ################################################################################ - - # If you are using this in your spec_helper.rb (or rails_helper.rb): - # - # ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config) - # - # with rspec then this controls what yarn command is run - # to automatically refresh your webpack assets on every test run. - # - config.build_test_command = "RAILS_ENV=test bin/webpack" - - ################################################################################ - ################################################################################ - # SERVER RENDERING OPTIONS - ################################################################################ - # This is the file used for server rendering of React when using `(prerender: true)` - # If you are never using server rendering, you should set this to "". - # Note, there is only one server bundle, unlike JavaScript where you want to minimize the size - # of the JS sent to the client. For the server rendering, React on Rails creates a pool of - # JavaScript execution instances which should handle any component requested. - # - # While you may configure this to be the same as your client bundle file, this file is typically - # different. You should have ONE server bundle which can create all of your server rendered - # React components. - # - config.server_bundle_js_file = "hello-world-bundle.js" -end diff --git a/config/routes.rb b/config/routes.rb index bbdd490..787824f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,3 @@ Rails.application.routes.draw do - get 'hello_world', to: 'hello_world#index' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end