lib/generators/hyperloop/install_generator.rb in hyper-rails-0.4.0 vs lib/generators/hyperloop/install_generator.rb in hyper-rails-0.4.1
- old
+ new
@@ -8,10 +8,12 @@
def inject_react_file_js
prepend_file 'app/assets/javascripts/application.js' do
<<-'JS'
// added by hyper-rails: These lines must preceed other requires especially turbo_links
+//= require 'opal'
+//= require 'react/react-source'
//= require 'components'
//= require 'react_ujs'
JS
end
append_file 'app/assets/javascripts/application.js', "Opal.load('components');\n"
@@ -53,11 +55,10 @@
def create_manifests
create_file 'app/views/components.rb', <<-FILE
# app/views/components.rb
require 'opal'
-require 'react/react-source'
require 'hyper-react'
if React::IsomorphicHelpers.on_opal_client?
require 'opal-jquery'
require 'browser'
require 'browser/interval'
@@ -71,33 +72,30 @@
FILE
if options[:'hyper-mesh'] || options[:all]
create_file 'app/models/models.rb', <<-FILE
# app/models/models.rb
-require_tree './public'
+require_tree './public' if RUBY_ENGINE == 'opal'
FILE
end
end
def add_config
application 'config.assets.paths << ::Rails.root.join(\'app\', \'models\').to_s'
- application 'config.autoload_paths += %W(#{config.root}/app/views/components)'
if options[:'hyper-mesh'] || options[:all]
application 'config.autoload_paths += %W(#{config.root}/app/models/public)'
end
- application 'config.eager_load_paths += %W(#{config.root}/app/views/components)'
if options[:'hyper-mesh'] || options[:all]
application 'config.eager_load_paths += %W(#{config.root}/app/models/public)'
end
application 'config.watchable_files.concat Dir["#{config.root}/app/views/**/*.rb"]',
env: :development
application 'config.react.variant = :development', env: :development
end
def add_gems
-
- gem "opal-rails"
- gem "opal-browser"
+ gem 'opal-rails'
+ gem 'opal-browser'
gem 'hyper-react'
gem 'therubyracer', platforms: :ruby
# optional gems
if options[:'hyper-router'] || options[:all]