Skip to content

Instantly share code, notes, and snippets.

@tfrcm
Last active June 28, 2017 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfrcm/0c22b14f9d8a1a881ad678210c0424ea to your computer and use it in GitHub Desktop.
Save tfrcm/0c22b14f9d8a1a881ad678210c0424ea to your computer and use it in GitHub Desktop.
webpackerでRailsにReactを導入するまでの手順書 ref: http://qiita.com/gcfuji/items/8b56fd1855a891734204
$ rails new my_app
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
...
# webpackerを追加
gem 'webpacker'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
...
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
$ yarn start
$ rails webpacker:install
$ rails webpacker:install:react
$ rails g controller tests index
$ bin/webpack-dev-server
<div id="mountNode"></div>
<%= javascript_pack_tag 'hello_react' %>
...
"scripts": {
"start": "rails s & bin/webpack-dev-server"
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment