Commit e37ee660 authored by Eugen Rochko's avatar Eugen Rochko

Upgrade to Rails 5.2 and add webpacker

parent d0254b1d
{
"presets": [
[
"env",
{
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}
],
"react"
],
"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread",
[
"transform-class-properties",
{
"spec": true
}
]
]
}
...@@ -16,3 +16,8 @@ ...@@ -16,3 +16,8 @@
# Ignore Byebug command history file. # Ignore Byebug command history file.
.byebug_history .byebug_history
.env .env
/public/packs
/public/packs-test
/node_modules
yarn-debug.log*
.yarn-integrity
plugins:
postcss-import: {}
postcss-cssnext: {}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '>= 2.3.0', '< 2.6.0' ruby '>= 2.3.0', '< 2.6.0'
gem 'rails', '~> 5.1.0' gem 'rails', '~> 5.2.0'
gem 'pg', '~> 0.20' gem 'pg', '~> 0.20'
gem 'puma', '~> 3.10' gem 'puma', '~> 3.10'
gem 'sass-rails', '~> 5.0' gem 'sass-rails', '~> 5.0'
...@@ -14,10 +14,10 @@ gem 'uglifier' ...@@ -14,10 +14,10 @@ gem 'uglifier'
gem 'bootsnap' gem 'bootsnap'
gem 'mastodon-api', require: 'mastodon', git: 'https://github.com/tootsuite/mastodon-api' gem 'mastodon-api', require: 'mastodon', git: 'https://github.com/tootsuite/mastodon-api'
gem 'twitter', git: 'https://github.com/sferik/twitter' gem 'twitter', git: 'https://github.com/sferik/twitter'
gem 'devise', '~> 4.3' gem 'devise', '~> 4.4'
gem 'omniauth-twitter' gem 'omniauth-twitter'
gem 'omniauth-mastodon', '>= 0.9.2' gem 'omniauth-mastodon', '>= 0.9.2'
gem 'hamlit-rails', '~> 0.2' gem 'hamlit-rails'
gem 'fast_blank', '~> 1.0' gem 'fast_blank', '~> 1.0'
gem 'dotenv-rails', '~> 2.2' gem 'dotenv-rails', '~> 2.2'
gem 'http' gem 'http'
...@@ -26,7 +26,7 @@ gem 'hiredis', '~> 0.6' ...@@ -26,7 +26,7 @@ gem 'hiredis', '~> 0.6'
gem 'redis', '~> 3.3', require: ['redis', 'redis/connection/hiredis'] gem 'redis', '~> 3.3', require: ['redis', 'redis/connection/hiredis']
gem 'sidekiq', '~> 5.0' gem 'sidekiq', '~> 5.0'
gem 'sidekiq-status' gem 'sidekiq-status'
gem 'redis-rails', '~> 5.0' gem 'redis-rails'
gem 'oj' gem 'oj'
gem 'react_on_rails', '11.0.0' gem 'react_on_rails', '11.0.0'
...@@ -43,6 +43,9 @@ group :development do ...@@ -43,6 +43,9 @@ group :development do
end end
group :production do group :production do
gem 'lograge', '~> 0.5' gem 'lograge'
gem 'rails_12factor' gem 'rails_12factor'
end end
gem 'mini_racer', platforms: :ruby
gem 'webpacker', '~> 3.5'
GIT GIT
remote: https://github.com/sferik/twitter remote: https://github.com/sferik/twitter
revision: d6c5100447e2c12d83bae26810632081ac0b69f5 revision: 16a54994c5a736c32914aeff786590833f0b09a9
specs: specs:
twitter (6.2.0) twitter (6.2.0)
addressable (~> 2.3) addressable (~> 2.3)
...@@ -16,7 +16,7 @@ GIT ...@@ -16,7 +16,7 @@ GIT
GIT GIT
remote: https://github.com/tootsuite/mastodon-api remote: https://github.com/tootsuite/mastodon-api
revision: 6557c5cc580f611c75da5f77280ec1dc571d08e0 revision: 189deb8219ae1ce7c34386d9ad1ca7e4a5fec62c
specs: specs:
mastodon-api (1.2.0) mastodon-api (1.2.0)
addressable (~> 2.5) addressable (~> 2.5)
...@@ -27,54 +27,58 @@ GIT ...@@ -27,54 +27,58 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (5.1.2) actioncable (5.2.0)
actionpack (= 5.1.2) actionpack (= 5.2.0)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (~> 0.6.1) websocket-driver (>= 0.6.1)
actionmailer (5.1.2) actionmailer (5.2.0)
actionpack (= 5.1.2) actionpack (= 5.2.0)
actionview (= 5.1.2) actionview (= 5.2.0)
activejob (= 5.1.2) activejob (= 5.2.0)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (5.1.2) actionpack (5.2.0)
actionview (= 5.1.2) actionview (= 5.2.0)
activesupport (= 5.1.2) activesupport (= 5.2.0)
rack (~> 2.0) rack (~> 2.0)
rack-test (~> 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.2) actionview (5.2.0)
activesupport (= 5.1.2) activesupport (= 5.2.0)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.2) activejob (5.2.0)
activesupport (= 5.1.2) activesupport (= 5.2.0)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (5.1.2) activemodel (5.2.0)
activesupport (= 5.1.2) activesupport (= 5.2.0)
activerecord (5.1.2) activerecord (5.2.0)
activemodel (= 5.1.2) activemodel (= 5.2.0)
activesupport (= 5.1.2) activesupport (= 5.2.0)
arel (~> 8.0) arel (>= 9.0)
activesupport (5.1.2) activestorage (5.2.0)
actionpack (= 5.2.0)
activerecord (= 5.2.0)
marcel (~> 0.3.1)
activesupport (5.2.0)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.2) addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 4.0)
arel (8.0.0) arel (9.0.0)
bcrypt (3.1.11) bcrypt (3.1.12)
better_errors (2.4.0) better_errors (2.4.0)
coderay (>= 1.0.0) coderay (>= 1.0.0)
erubi (>= 1.0.0) erubi (>= 1.0.0)
rack (>= 0.9.0) rack (>= 0.9.0)
binding_of_caller (0.7.3) binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
bootsnap (1.1.1) bootsnap (1.3.0)
msgpack (~> 1.0) msgpack (~> 1.0)
buftok (0.2.0) buftok (0.2.0)
builder (3.2.3) builder (3.2.3)
...@@ -83,31 +87,31 @@ GEM ...@@ -83,31 +87,31 @@ GEM
coderay (1.1.2) coderay (1.1.2)
colorize (0.8.1) colorize (0.8.1)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
connection_pool (2.2.1) connection_pool (2.2.2)
crass (1.0.3) crass (1.0.4)
debug_inspector (0.0.3) debug_inspector (0.0.3)
devise (4.4.0) devise (4.4.3)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2) railties (>= 4.1.0, < 6.0)
responders responders
warden (~> 1.2.3) warden (~> 1.2.3)
domain_name (0.5.20170404) domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
dotenv (2.2.1) dotenv (2.4.0)
dotenv-rails (2.2.1) dotenv-rails (2.4.0)
dotenv (= 2.2.1) dotenv (= 2.4.0)
railties (>= 3.2, < 5.2) railties (>= 3.2, < 6.0)
equalizer (0.0.11) equalizer (0.0.11)
erubi (1.7.0) erubi (1.7.1)
execjs (2.7.0) execjs (2.7.0)
faraday (0.12.2) faraday (0.12.2)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
fast_blank (1.0.0) fast_blank (1.0.0)
ffi (1.9.18) ffi (1.9.25)
font-awesome-rails (4.7.0.2) font-awesome-rails (4.7.0.4)
railties (>= 3.2, < 5.2) railties (>= 3.2, < 6.0)
globalid (0.4.0) globalid (0.4.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
hamlit (2.8.8) hamlit (2.8.8)
temple (>= 0.8.0) temple (>= 0.8.0)
...@@ -120,52 +124,57 @@ GEM ...@@ -120,52 +124,57 @@ GEM
railties (>= 4.0.1) railties (>= 4.0.1)
hashie (3.5.7) hashie (3.5.7)
hiredis (0.6.1) hiredis (0.6.1)
http (3.0.0) http (3.3.0)
addressable (~> 2.3) addressable (~> 2.3)
http-cookie (~> 1.0) http-cookie (~> 1.0)
http-form_data (>= 2.0.0.pre.pre2, < 3) http-form_data (~> 2.0)
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
http-cookie (1.0.3) http-cookie (1.0.3)
domain_name (~> 0.5) domain_name (~> 0.5)
http-form_data (2.0.0) http-form_data (2.1.1)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
httplog (0.99.7) httplog (0.99.7)
colorize colorize
rack rack
i18n (0.9.1) i18n (1.0.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jquery-rails (4.3.1) jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
jwt (1.5.6) jwt (1.5.6)
libv8 (6.3.292.48.1)
listen (3.0.8) listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
lograge (0.5.1) lograge (0.10.0)
actionpack (>= 4, < 5.2) actionpack (>= 4)
activesupport (>= 4, < 5.2) activesupport (>= 4)
railties (>= 4, < 5.2) railties (>= 4)
loofah (2.1.1) request_store (~> 1.0)
loofah (2.2.2)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.6.6) mail (2.7.0)
mime-types (>= 1.16, < 4) mini_mime (>= 0.1.1)
marcel (0.3.2)
mimemagic (~> 0.3.2)
memoizable (0.4.2) memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1) thread_safe (~> 0.3, >= 0.3.1)
method_source (0.8.2) method_source (0.9.0)
mime-types (3.1) mimemagic (0.3.2)
mime-types-data (~> 3.2015) mini_mime (1.0.0)
mime-types-data (3.2016.0521)
mini_portile2 (2.3.0) mini_portile2 (2.3.0)
minitest (5.11.1) mini_racer (0.1.15)
msgpack (1.1.0) libv8 (~> 6.3)
multi_json (1.12.1) minitest (5.11.3)
msgpack (1.2.4)
multi_json (1.13.1)
multi_xml (0.6.0) multi_xml (0.6.0)
multipart-post (2.0.0) multipart-post (2.0.0)
naught (1.1.0) naught (1.1.0)
nio4r (2.1.0) nio4r (2.3.1)
nokogiri (1.8.1) nokogiri (1.8.2)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
numerizer (0.1.1) numerizer (0.1.1)
oauth (0.5.4) oauth (0.5.4)
...@@ -175,7 +184,7 @@ GEM ...@@ -175,7 +184,7 @@ GEM
multi_json (~> 1.3) multi_json (~> 1.3)
multi_xml (~> 0.5) multi_xml (~> 0.5)
rack (>= 1.2, < 3) rack (>= 1.2, < 3)
oj (3.3.10) oj (3.6.2)
omniauth (1.8.1) omniauth (1.8.1)
hashie (>= 3.4.6, < 3.6.0) hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3) rack (>= 1.6.2, < 3)
...@@ -185,58 +194,61 @@ GEM ...@@ -185,58 +194,61 @@ GEM
omniauth-oauth (1.1.0) omniauth-oauth (1.1.0)
oauth oauth
omniauth (~> 1.0) omniauth (~> 1.0)
omniauth-oauth2 (1.4.0) omniauth-oauth2 (1.5.0)
oauth2 (~> 1.0) oauth2 (~> 1.1)
omniauth (~> 1.2) omniauth (~> 1.2)
omniauth-twitter (1.4.0) omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1) omniauth-oauth (~> 1.1)
rack rack
orm_adapter (0.5.0) orm_adapter (0.5.0)
pg (0.21.0) pg (0.21.0)
pry (0.11.0) pry (0.11.3)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.9.0)
pry-rails (0.3.6) pry-rails (0.3.6)
pry (>= 0.10.4) pry (>= 0.10.4)
public_suffix (3.0.1) public_suffix (3.0.2)
puma (3.11.0) puma (3.11.4)
rack (2.0.5) rack (2.0.5)
rack-protection (2.0.0) rack-protection (2.0.3)
rack rack
rack-test (0.6.3) rack-proxy (0.6.4)
rack (>= 1.0) rack
rails (5.1.2) rack-test (1.0.0)
actioncable (= 5.1.2) rack (>= 1.0, < 3)
actionmailer (= 5.1.2) rails (5.2.0)
actionpack (= 5.1.2) actioncable (= 5.2.0)
actionview (= 5.1.2) actionmailer (= 5.2.0)
activejob (= 5.1.2) actionpack (= 5.2.0)
activemodel (= 5.1.2) actionview (= 5.2.0)
activerecord (= 5.1.2) activejob (= 5.2.0)
activesupport (= 5.1.2) activemodel (= 5.2.0)
bundler (>= 1.3.0, < 2.0) activerecord (= 5.2.0)
railties (= 5.1.2) activestorage (= 5.2.0)
activesupport (= 5.2.0)
bundler (>= 1.3.0)
railties (= 5.2.0)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3) rails-html-sanitizer (1.0.4)
loofah (~> 2.0) loofah (~> 2.2, >= 2.2.2)
rails_12factor (0.0.3) rails_12factor (0.0.3)
rails_serve_static_assets rails_serve_static_assets
rails_stdout_logging rails_stdout_logging
rails_serve_static_assets (0.0.5) rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5) rails_stdout_logging (0.0.5)
railties (5.1.2) railties (5.2.0)
actionpack (= 5.1.2) actionpack (= 5.2.0)
activesupport (= 5.1.2) activesupport (= 5.2.0)
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rainbow (2.2.2) rainbow (2.2.2)
rake rake
rake (12.3.0) rake (12.3.1)
rb-fsevent (0.10.2) rb-fsevent (0.10.3)
rb-inotify (0.9.10) rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2) ffi (>= 0.5.0, < 2)
react_on_rails (11.0.0) react_on_rails (11.0.0)
...@@ -260,27 +272,29 @@ GEM ...@@ -260,27 +272,29 @@ GEM
redis-actionpack (>= 5.0, < 6) redis-actionpack (>= 5.0, < 6)
redis-activesupport (>= 5.0, < 6) redis-activesupport (>= 5.0, < 6)
redis-store (>= 1.2, < 2) redis-store (>= 1.2, < 2)
redis-store (1.4.1) redis-store (1.5.0)
redis (>= 2.2, < 5) redis (>= 2.2, < 5)
request_store (1.4.1)
rack (>= 1.4)
responders (2.4.0) responders (2.4.0)
actionpack (>= 4.2.0, < 5.3) actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3)
sass (3.5.1) sass (3.5.6)
sass-listen (~> 4.0.0) sass-listen (~> 4.0.0)
sass-listen (4.0.0) sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.6) sass-rails (5.0.7)
railties (>= 4.0.0, < 6) railties (>= 4.0.0, < 6)
sass (~> 3.1) sass (~> 3.1)
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0) sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
sidekiq (5.0.5) sidekiq (5.1.3)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0) connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0) rack-protection (>= 1.5.0)
redis (>= 3.3.4, < 5) redis (>= 3.3.5, < 5)
sidekiq-status (1.0.1) sidekiq-status (1.0.1)
chronic_duration chronic_duration
sidekiq (>= 3.0) sidekiq (>= 3.0)
...@@ -293,7 +307,7 @@ GEM ...@@ -293,7 +307,7 @@ GEM
sprockets (3.7.1) sprockets (3.7.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (> 1, < 3) rack (> 1, < 3)
sprockets-rails (3.2.0) sprockets-rails (3.2.1)
actionpack (>= 4.0) actionpack (>= 4.0)
activesupport (>= 4.0) activesupport (>= 4.0)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
...@@ -301,18 +315,22 @@ GEM ...@@ -301,18 +315,22 @@ GEM
thor (0.20.0) thor (0.20.0)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.8) tilt (2.0.8)
tzinfo (1.2.4) tzinfo (1.2.5)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (3.2.0) uglifier (4.1.11)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.7.4) unf_ext (0.0.7.5)
warden (1.2.7) warden (1.2.7)
rack (>= 1.0) rack (>= 1.0)
websocket-driver (0.6.5) webpacker (3.5.3)
activesupport (>= 4.2)
rack-proxy (>= 0.6.1)
railties (>= 4.2)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2) websocket-extensions (0.1.3)
PLATFORMS PLATFORMS
ruby ruby
...@@ -321,29 +339,30 @@ DEPENDENCIES ...@@ -321,29 +339,30 @@ DEPENDENCIES
better_errors (~> 2.4) better_errors (~> 2.4)
binding_of_caller (~> 0.7) binding_of_caller (~> 0.7)
bootsnap bootsnap
devise (~> 4.3) devise (~> 4.4)
dotenv-rails (~> 2.2) dotenv-rails (~> 2.2)
fast_blank (~> 1.0) fast_blank (~> 1.0)
font-awesome-rails font-awesome-rails
hamlit-rails (~> 0.2) hamlit-rails
hiredis (~> 0.6) hiredis (~> 0.6)
http http
httplog (~> 0.99) httplog (~> 0.99)
jquery-rails jquery-rails
listen (~> 3.0.5) listen (~> 3.0.5)
lograge (~> 0.5) lograge
mastodon-api! mastodon-api!
mini_racer
oj oj
omniauth-mastodon (>= 0.9.2) omniauth-mastodon (>= 0.9.2)
omniauth-twitter omniauth-twitter
pg (~> 0.20) pg (~> 0.20)
pry-rails (~> 0.3) pry-rails (~> 0.3)
puma (~> 3.10) puma (~> 3.10)
rails (~> 5.1.0) rails (~> 5.2.0)
rails_12factor rails_12factor
react_on_rails (= 11.0.0) react_on_rails (= 11.0.0)
redis (~> 3.3) redis (~> 3.3)
redis-rails (~> 5.0) redis-rails
sass-rails (~> 5.0) sass-rails (~> 5.0)
sidekiq (~> 5.0) sidekiq (~> 5.0)
sidekiq-status sidekiq-status
...@@ -351,6 +370,7 @@ DEPENDENCIES ...@@ -351,6 +370,7 @@ DEPENDENCIES
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
twitter! twitter!
uglifier uglifier
webpacker (~> 3.5)
RUBY VERSION RUBY VERSION
ruby 2.4.1p111 ruby 2.4.1p111
......
# 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'
# 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'
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 (
<div>
<h3>
Hello, {this.state.name}!
</h3>
<hr />
<form >
<label htmlFor="name">
Say hello to:
</label>
<input
id="name"
type="text"
value={this.state.name}
onChange={(e) => this.updateName(e.target.value)}
/>
</form>
</div>
);
}
}
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb
console.log('Hello World from Webpacker')
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,
});
// Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file,
// like app/views/layouts/application.html.erb. All it does is render <div>Hello React</div> at the bottom
// of the page.
import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
const Hello = props => (
<div>Hello {props.name}!</div>
)
Hello.defaultProps = {
name: 'David'
}
Hello.propTypes = {
name: PropTypes.string
}
document.addEventListener