shakapacker 7.0.0.rc.0 → 7.0.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +4 -8
  3. data/.github/workflows/dummy.yml +21 -0
  4. data/.github/workflows/generator.yml +37 -0
  5. data/.github/workflows/jest.yml +2 -2
  6. data/.github/workflows/js-lint.yml +2 -2
  7. data/.github/workflows/rubocop.yml +1 -1
  8. data/.github/workflows/ruby-backward-compatibility.yml +2 -6
  9. data/.github/workflows/ruby.yml +2 -6
  10. data/.gitignore +3 -0
  11. data/CHANGELOG.md +17 -18
  12. data/CONTRIBUTING.md +76 -20
  13. data/README.md +5 -1
  14. data/Rakefile +44 -8
  15. data/docs/deployment.md +1 -2
  16. data/lib/install/binstubs.rb +3 -1
  17. data/lib/install/config/shakapacker.yml +9 -0
  18. data/lib/install/config/webpack/webpack.config.js +3 -2
  19. data/lib/install/template.rb +27 -15
  20. data/lib/shakapacker/deprecation_helper.rb +4 -5
  21. data/lib/shakapacker/version.rb +1 -1
  22. data/lib/tasks/shakapacker/check_binstubs.rake +14 -10
  23. data/lib/tasks/shakapacker/compile.rake +1 -6
  24. data/package/__tests__/index-bc.js +22 -0
  25. data/package/environments/__tests__/base-bc.js +2 -2
  26. data/package/environments/__tests__/base.js +2 -2
  27. data/package/environments/__tests__/development.js +53 -0
  28. data/package/environments/__tests__/production.js +53 -0
  29. data/package/environments/base.js +4 -3
  30. data/package/environments/production.js +9 -0
  31. data/package/index.js +24 -1
  32. data/package/utils/helpers.js +1 -1
  33. data/package.json +1 -1
  34. data/spec/dummy/.browserslistrc +1 -0
  35. data/spec/dummy/.gitignore +20 -0
  36. data/spec/dummy/.prettierrc.yaml +4 -0
  37. data/spec/dummy/Gemfile +63 -0
  38. data/spec/dummy/Procfile.dev +5 -0
  39. data/spec/dummy/Procfile.dev-static +9 -0
  40. data/spec/dummy/README.md +1 -0
  41. data/spec/dummy/Rakefile +6 -0
  42. data/spec/dummy/app/assets/config/manifest.js +2 -0
  43. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  44. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  45. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  46. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  47. data/spec/dummy/app/controllers/hello_world_controller.rb +9 -0
  48. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  49. data/spec/dummy/app/javascript/Globals.d.ts +3 -0
  50. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +25 -0
  51. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx +47 -0
  52. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorldServer.tsx +5 -0
  53. data/spec/dummy/app/javascript/bundles/HelloWorld/components/logo.svg +7 -0
  54. data/spec/dummy/app/javascript/packs/application.js +17 -0
  55. data/spec/dummy/app/javascript/packs/hello-world-bundle.ts +8 -0
  56. data/spec/dummy/app/javascript/packs/server-bundle.ts +8 -0
  57. data/spec/dummy/app/jobs/application_job.rb +7 -0
  58. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  59. data/spec/dummy/app/models/application_record.rb +3 -0
  60. data/spec/dummy/app/models/concerns/.keep +0 -0
  61. data/spec/dummy/app/views/hello_world/index.html.erb +2 -0
  62. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  63. data/spec/dummy/app/views/layouts/hello_world.html.erb +13 -0
  64. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  65. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  66. data/spec/dummy/babel.config.js +30 -0
  67. data/spec/dummy/bin/bundle +114 -0
  68. data/spec/dummy/bin/dev +30 -0
  69. data/spec/dummy/bin/dev-static +30 -0
  70. data/spec/dummy/bin/rails +9 -0
  71. data/spec/dummy/bin/rake +9 -0
  72. data/spec/dummy/bin/setup +33 -0
  73. data/spec/dummy/bin/shakapacker +13 -0
  74. data/spec/dummy/bin/shakapacker-dev-server +13 -0
  75. data/spec/dummy/bin/spring +17 -0
  76. data/spec/dummy/bin/yarn +18 -0
  77. data/spec/dummy/config/application.rb +32 -0
  78. data/spec/dummy/config/boot.rb +4 -0
  79. data/spec/dummy/config/cable.yml +10 -0
  80. data/spec/dummy/config/credentials.yml.enc +1 -0
  81. data/spec/dummy/config/database.yml +25 -0
  82. data/spec/dummy/config/environment.rb +5 -0
  83. data/spec/dummy/config/environments/development.rb +54 -0
  84. data/spec/dummy/config/environments/production.rb +106 -0
  85. data/spec/dummy/config/environments/test.rb +49 -0
  86. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  87. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  88. data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
  89. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  90. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  91. data/spec/dummy/config/initializers/inflections.rb +16 -0
  92. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  93. data/spec/dummy/config/initializers/react_on_rails.rb +58 -0
  94. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  95. data/spec/dummy/config/locales/en.yml +33 -0
  96. data/spec/dummy/config/puma.rb +38 -0
  97. data/spec/dummy/config/routes.rb +6 -0
  98. data/spec/dummy/config/shakapacker.yml +62 -0
  99. data/spec/dummy/config/spring.rb +6 -0
  100. data/spec/dummy/config/storage.yml +34 -0
  101. data/spec/dummy/config/webpack/ServerClientOrBoth.js +34 -0
  102. data/spec/dummy/config/webpack/clientWebpackConfig.js +15 -0
  103. data/spec/dummy/config/webpack/commonWebpackConfig.js +18 -0
  104. data/spec/dummy/config/webpack/development.js +32 -0
  105. data/spec/dummy/config/webpack/production.js +9 -0
  106. data/spec/dummy/config/webpack/serverWebpackConfig.js +116 -0
  107. data/spec/dummy/config/webpack/test.js +7 -0
  108. data/spec/dummy/config/webpack/webpack.config.js +24 -0
  109. data/spec/dummy/config.ru +5 -0
  110. data/spec/dummy/db/seeds.rb +7 -0
  111. data/spec/dummy/lib/assets/.keep +0 -0
  112. data/spec/dummy/lib/tasks/.keep +0 -0
  113. data/spec/dummy/package.json +44 -0
  114. data/spec/dummy/postcss.config.js +12 -0
  115. data/spec/dummy/public/404.html +67 -0
  116. data/spec/dummy/public/422.html +67 -0
  117. data/spec/dummy/public/500.html +66 -0
  118. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  119. data/spec/dummy/public/apple-touch-icon.png +0 -0
  120. data/spec/dummy/public/favicon.ico +0 -0
  121. data/spec/dummy/public/robots.txt +1 -0
  122. data/spec/dummy/spec/rails_helper.rb +118 -0
  123. data/spec/dummy/spec/spec_helper.rb +96 -0
  124. data/spec/dummy/spec/system/hello_world_spec.rb +19 -0
  125. data/spec/dummy/tsconfig.json +21 -0
  126. data/spec/dummy/vendor/.keep +0 -0
  127. data/spec/dummy/yarn.lock +4697 -0
  128. data/spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb +4 -0
  129. data/spec/generator_specs/e2e_template/files/app/javascript/components/App.js +12 -0
  130. data/spec/generator_specs/e2e_template/files/app/javascript/packs/application.js +10 -0
  131. data/spec/generator_specs/e2e_template/files/app/views/home/index.html.erb +2 -0
  132. data/spec/generator_specs/e2e_template/files/app/views/layouts/application.html.erb +17 -0
  133. data/spec/generator_specs/e2e_template/files/config/routes.rb +3 -0
  134. data/spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb +13 -0
  135. data/spec/generator_specs/e2e_template/template.rb +21 -0
  136. data/spec/generator_specs/generator_spec.rb +169 -0
  137. data/spec/{configuration_spec.rb → shakapacker/configuration_spec.rb} +10 -10
  138. data/spec/{dev_server_runner_spec.rb → shakapacker/dev_server_runner_spec.rb} +1 -1
  139. data/spec/{engine_rake_tasks_spec.rb → shakapacker/engine_rake_tasks_spec.rb} +2 -2
  140. data/spec/{manifest_spec.rb → shakapacker/manifest_spec.rb} +1 -1
  141. data/spec/shakapacker/rake_tasks_spec.rb +93 -0
  142. data/spec/{spec_helper_initializer.rb → shakapacker/spec_helper_initializer.rb} +1 -1
  143. data/spec/shakapacker/test_app/config/webpack/webpack.config.js +0 -0
  144. data/spec/shakapacker/test_app/some.config.js +0 -0
  145. data/spec/{version_checker_spec.rb → shakapacker/version_checker_spec.rb} +9 -9
  146. data/spec/{webpack_runner_spec.rb → shakapacker/webpack_runner_spec.rb} +1 -1
  147. metadata +173 -64
  148. data/gemfiles/Gemfile-rails.5.2.x +0 -9
  149. data/spec/rake_tasks_spec.rb +0 -34
  150. /data/docs/{developing_webpacker.md → developing_shakapacker.md} +0 -0
  151. /data/spec/backward_compatibility_specs/{command_spec_bc.rb → command_spec.rb} +0 -0
  152. /data/spec/backward_compatibility_specs/{compiler_spec_bc.rb → compiler_spec.rb} +0 -0
  153. /data/spec/backward_compatibility_specs/{compiler_strategy_spec_bc.rb → compiler_strategy_spec.rb} +0 -0
  154. /data/spec/backward_compatibility_specs/{configuration_spec_bc.rb → configuration_spec.rb} +0 -0
  155. /data/spec/backward_compatibility_specs/{dev_server_runner_spec_bc.rb → dev_server_runner_spec.rb} +0 -0
  156. /data/spec/backward_compatibility_specs/{dev_server_spec_bc.rb → dev_server_spec.rb} +0 -0
  157. /data/spec/backward_compatibility_specs/{digest_strategy_spec_bc.rb → digest_strategy_spec.rb} +0 -0
  158. /data/spec/backward_compatibility_specs/{engine_rake_tasks_spec_bc.rb → engine_rake_tasks_spec.rb} +0 -0
  159. /data/spec/backward_compatibility_specs/{env_spec_bc.rb → env_spec.rb} +0 -0
  160. /data/spec/backward_compatibility_specs/{helper_spec_bc.rb → helper_spec.rb} +0 -0
  161. /data/spec/backward_compatibility_specs/{instance_spec_bc.rb → instance_spec.rb} +0 -0
  162. /data/spec/backward_compatibility_specs/{manifest_spec_bc.rb → manifest_spec.rb} +0 -0
  163. /data/spec/backward_compatibility_specs/{mtime_strategy_spec_bc.rb → mtime_strategy_spec.rb} +0 -0
  164. /data/spec/backward_compatibility_specs/{rake_tasks_spec_bc.rb → rake_tasks_spec.rb} +0 -0
  165. /data/spec/backward_compatibility_specs/{webpack_runner_spec_bc.rb → webpack_runner_spec.rb} +0 -0
  166. /data/spec/backward_compatibility_specs/{webpacker_spec_bc.rb → webpacker_spec.rb} +0 -0
  167. /data/spec/{test_app/config/webpack/webpack.config.js → dummy/app/assets/images/.keep} +0 -0
  168. /data/spec/{test_app/some.config.js → dummy/app/controllers/concerns/.keep} +0 -0
  169. /data/spec/{command_spec.rb → shakapacker/command_spec.rb} +0 -0
  170. /data/spec/{compiler_spec.rb → shakapacker/compiler_spec.rb} +0 -0
  171. /data/spec/{compiler_strategy_spec.rb → shakapacker/compiler_strategy_spec.rb} +0 -0
  172. /data/spec/{dev_server_spec.rb → shakapacker/dev_server_spec.rb} +0 -0
  173. /data/spec/{digest_strategy_spec.rb → shakapacker/digest_strategy_spec.rb} +0 -0
  174. /data/spec/{env_spec.rb → shakapacker/env_spec.rb} +0 -0
  175. /data/spec/{helper_spec.rb → shakapacker/helper_spec.rb} +0 -0
  176. /data/spec/{instance_spec.rb → shakapacker/instance_spec.rb} +0 -0
  177. /data/spec/{mtime_strategy_spec.rb → shakapacker/mtime_strategy_spec.rb} +0 -0
  178. /data/spec/{webpacker_spec.rb → shakapacker/shakapacker_spec.rb} +0 -0
  179. /data/spec/{test_app → shakapacker/test_app}/.gitignore +0 -0
  180. /data/spec/{test_app → shakapacker/test_app}/Rakefile +0 -0
  181. /data/spec/{test_app → shakapacker/test_app}/app/javascript/entrypoints/application.js +0 -0
  182. /data/spec/{test_app → shakapacker/test_app}/app/javascript/entrypoints/generated/something.js +0 -0
  183. /data/spec/{test_app → shakapacker/test_app}/app/javascript/entrypoints/multi_entry.css +0 -0
  184. /data/spec/{test_app → shakapacker/test_app}/app/javascript/entrypoints/multi_entry.js +0 -0
  185. /data/spec/{test_app → shakapacker/test_app}/bin/shakapacker +0 -0
  186. /data/spec/{test_app → shakapacker/test_app}/bin/shakapacker-dev-server +0 -0
  187. /data/spec/{test_app → shakapacker/test_app}/config/application.rb +0 -0
  188. /data/spec/{test_app → shakapacker/test_app}/config/environment.rb +0 -0
  189. /data/spec/{test_app → shakapacker/test_app}/config/initializers/inspect_autoload_paths.rb +0 -0
  190. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker.yml +0 -0
  191. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_css_extract_ignore_order_warnings.yml +0 -0
  192. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_defaults_fallback.yml +0 -0
  193. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_manifest_path.yml +0 -0
  194. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_nested_entries.yml +0 -0
  195. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_no_precompile.yml +0 -0
  196. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_other_location.yml +0 -0
  197. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_public_root.yml +0 -0
  198. /data/spec/{test_app → shakapacker/test_app}/config.ru +0 -0
  199. /data/spec/{test_app → shakapacker/test_app}/package.json +0 -0
  200. /data/spec/{test_app → shakapacker/test_app}/public/packs/manifest.json +0 -0
  201. /data/spec/{test_app → shakapacker/test_app}/yarn.lock +0 -0
@@ -0,0 +1,49 @@
1
+ # The test environment is used exclusively to run your application's
2
+ # test suite. You never need to work with it otherwise. Remember that
3
+ # your test database is "scratch space" for the test suite and is wiped
4
+ # and recreated between test runs. Don't rely on the data there!
5
+
6
+ Rails.application.configure do
7
+ # Settings specified here will take precedence over those in config/application.rb.
8
+
9
+ config.cache_classes = false
10
+ config.action_view.cache_template_loading = true
11
+
12
+ # Do not eager load code on boot. This avoids loading your whole application
13
+ # just for the purpose of running a single test. If you are using a tool that
14
+ # preloads Rails for running tests, you may have to set it to true.
15
+ config.eager_load = false
16
+
17
+ # Configure public file server for tests with Cache-Control for performance.
18
+ config.public_file_server.enabled = true
19
+ config.public_file_server.headers = {
20
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
21
+ }
22
+
23
+ # Show full error reports and disable caching.
24
+ config.consider_all_requests_local = true
25
+ config.action_controller.perform_caching = false
26
+ config.cache_store = :null_store
27
+
28
+ # Raise exceptions instead of rendering exception templates.
29
+ config.action_dispatch.show_exceptions = false
30
+
31
+ # Disable request forgery protection in test environment.
32
+ config.action_controller.allow_forgery_protection = false
33
+
34
+ # Store uploaded files on the local file system in a temporary directory.
35
+ config.active_storage.service = :test
36
+
37
+ config.action_mailer.perform_caching = false
38
+
39
+ # Tell Action Mailer not to deliver emails to the real world.
40
+ # The :test delivery method accumulates sent emails in the
41
+ # ActionMailer::Base.deliveries array.
42
+ config.action_mailer.delivery_method = :test
43
+
44
+ # Print deprecation notices to the stderr.
45
+ config.active_support.deprecation = :stderr
46
+
47
+ # Raises error for missing translations.
48
+ # config.action_view.raise_on_missing_translations = true
49
+ end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # ActiveSupport::Reloader.to_prepare do
4
+ # ApplicationController.renderer.defaults.merge!(
5
+ # http_host: 'example.org',
6
+ # https: false
7
+ # )
8
+ # end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,28 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide content security policy
4
+ # For further information see the following documentation
5
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6
+
7
+ # Rails.application.config.content_security_policy do |policy|
8
+ # policy.default_src :self, :https
9
+ # policy.font_src :self, :https, :data
10
+ # policy.img_src :self, :https, :data
11
+ # policy.object_src :none
12
+ # policy.script_src :self, :https
13
+ # policy.style_src :self, :https
14
+
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+
19
+ # If you are using UJS then enable automatic nonce generation
20
+ # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21
+
22
+ # Set the nonce only to specific directives
23
+ # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
24
+
25
+ # Report CSP violations to a specified URI
26
+ # For further information see the following documentation:
27
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
28
+ # Rails.application.config.content_security_policy_report_only = true
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Specify a serializer for the signed and encrypted cookie jars.
4
+ # Valid options are :json, :marshal, and :hybrid.
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # See https://github.com/shakacode/react_on_rails/blob/master/docs/guides/configuration.md
4
+ # for many more options.
5
+
6
+ ReactOnRails.configure do |config|
7
+ # This configures the script to run to build the production assets by webpack. Set this to nil
8
+ # if you don't want react_on_rails building this file for you.
9
+ # If nil, then the standard shakacode/shakapacker assets:precompile will run
10
+ # config.build_production_command = nil
11
+
12
+ ################################################################################
13
+ ################################################################################
14
+ # TEST CONFIGURATION OPTIONS
15
+ # Below options are used with the use of this test helper:
16
+ # ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
17
+ ################################################################################
18
+
19
+ # If you are using this in your spec_helper.rb (or rails_helper.rb):
20
+ #
21
+ # ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
22
+ #
23
+ # with rspec then this controls what yarn command is run
24
+ # to automatically refresh your webpack assets on every test run.
25
+ #
26
+ # Alternately, you can remove the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`
27
+ # and set the config/webpacker.yml option for test to true.
28
+ config.build_test_command = "RAILS_ENV=test bin/webpacker"
29
+
30
+ ################################################################################
31
+ ################################################################################
32
+ # SERVER RENDERING OPTIONS
33
+ ################################################################################
34
+ # This is the file used for server rendering of React when using `(prerender: true)`
35
+ # If you are never using server rendering, you should set this to "".
36
+ # Note, there is only one server bundle, unlike JavaScript where you want to minimize the size
37
+ # of the JS sent to the client. For the server rendering, React on Rails creates a pool of
38
+ # JavaScript execution instances which should handle any component requested.
39
+ #
40
+ # While you may configure this to be the same as your client bundle file, this file is typically
41
+ # different. You should have ONE server bundle which can create all of your server rendered
42
+ # React components.
43
+ #
44
+ config.server_bundle_js_file = "server-bundle.js"
45
+
46
+ ################################################################################
47
+ ################################################################################
48
+ # FILE SYSTEM BASED COMPONENT REGISTRY
49
+ ################################################################################
50
+ # `components_subdirectory` is the name of the matching directories that contain automatically registered components
51
+ # for use in the Rails views. The default is nil, you can enable the feature by updating it in the next line.
52
+ # config.components_subdirectory = "ror_components"
53
+ #
54
+ # For automated component registry, `render_component` view helper method tries to load bundle for component from
55
+ # generated directory. default is false, you can pass option at the time of individual usage or update the default
56
+ # in the following line
57
+ config.auto_load_bundle = false
58
+ end
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # 'true': 'foo'
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"
@@ -0,0 +1,38 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9
+ threads min_threads_count, max_threads_count
10
+
11
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
12
+ #
13
+ port ENV.fetch("PORT") { 3000 }
14
+
15
+ # Specifies the `environment` that Puma will run in.
16
+ #
17
+ environment ENV.fetch("RAILS_ENV") { "development" }
18
+
19
+ # Specifies the `pidfile` that Puma will use.
20
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
21
+
22
+ # Specifies the number of `workers` to boot in clustered mode.
23
+ # Workers are forked web server processes. If using threads and workers together
24
+ # the concurrency of the application would be max `threads` * `workers`.
25
+ # Workers do not work on JRuby or Windows (both of which do not support
26
+ # processes).
27
+ #
28
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
29
+
30
+ # Use the `preload_app!` method when specifying a `workers` number.
31
+ # This directive tells Puma to first boot the application and load code
32
+ # before forking the application. This takes advantage of Copy On Write
33
+ # process behavior so workers use less memory.
34
+ #
35
+ # preload_app!
36
+
37
+ # Allow puma to be restarted by `rails restart` command.
38
+ plugin :tmp_restart
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ get "hello_world", to: "hello_world#index"
3
+
4
+ get "/", to: redirect("/hello_world")
5
+ # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
6
+ end
@@ -0,0 +1,62 @@
1
+ # Note: You must restart bin/webpacker-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_root_path: public
7
+ public_output_path: packs
8
+ cache_path: tmp/webpacker
9
+ webpack_compile_output: true
10
+
11
+ # Additional paths webpack should lookup modules
12
+ # ['app/assets', 'engine/foo/app/assets']
13
+ additional_paths: []
14
+
15
+ # Reload manifest.json on all requests so we reload latest compiled packs
16
+ cache_manifest: false
17
+
18
+ development:
19
+ <<: *default
20
+ # This is false since we're running `bin/webpacker -w` in Procfile.dev-setic
21
+ compile: false
22
+
23
+ # Reference: https://webpack.js.org/configuration/dev-server/
24
+ dev_server:
25
+ https: false
26
+ host: localhost
27
+ port: 3035
28
+ # Hot Module Replacement updates modules while the application is running without a full reload
29
+ hmr: true
30
+ client:
31
+ # Should we show a full-screen overlay in the browser when there are compiler errors or warnings?
32
+ overlay: true
33
+ # May also be a string
34
+ # webSocketURL:
35
+ # hostname: "0.0.0.0"
36
+ # pathname: "/ws"
37
+ # port: 8080
38
+ compress: true
39
+ # Note that apps that do not check the host are vulnerable to DNS rebinding attacks
40
+ allowed_hosts: [ 'localhost' ]
41
+ pretty: true
42
+ headers:
43
+ 'Access-Control-Allow-Origin': '*'
44
+ static:
45
+ watch:
46
+ ignored: '**/node_modules/**'
47
+
48
+ test:
49
+ <<: *default
50
+ compile: true
51
+
52
+ # Compile test packs to a separate directory
53
+ public_output_path: packs-test
54
+
55
+ production:
56
+ <<: *default
57
+
58
+ # Production depends on precompilation of packs prior to booting for performance.
59
+ compile: false
60
+
61
+ # Cache manifest.json for performance
62
+ cache_manifest: true
@@ -0,0 +1,6 @@
1
+ Spring.watch(
2
+ ".ruby-version",
3
+ ".rbenv-vars",
4
+ "tmp/restart.txt",
5
+ "tmp/caching-dev.txt"
6
+ )
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket
23
+
24
+ # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,34 @@
1
+ const clientWebpackConfig = require('./clientWebpackConfig')
2
+ const serverWebpackConfig = require('./serverWebpackConfig')
3
+
4
+ const webpackConfig = (envSpecific) => {
5
+ const clientConfig = clientWebpackConfig()
6
+ const serverConfig = serverWebpackConfig()
7
+
8
+ if (envSpecific) {
9
+ envSpecific(clientConfig, serverConfig)
10
+ }
11
+
12
+ let result
13
+ // For HMR, need to separate the the client and server webpack configurations
14
+ if (process.env.WEBPACK_SERVE || process.env.CLIENT_BUNDLE_ONLY) {
15
+ // eslint-disable-next-line no-console
16
+ console.log('[React on Rails] Creating only the client bundles.')
17
+ result = clientConfig
18
+ } else if (process.env.SERVER_BUNDLE_ONLY) {
19
+ // eslint-disable-next-line no-console
20
+ console.log('[React on Rails] Creating only the server bundle.')
21
+ result = serverConfig
22
+ } else {
23
+ // default is the standard client and server build
24
+ // eslint-disable-next-line no-console
25
+ console.log('[React on Rails] Creating both client and server bundles.')
26
+ result = [clientConfig, serverConfig]
27
+ }
28
+
29
+ // To debug, uncomment next line and inspect "result"
30
+ // debugger
31
+ return result
32
+ }
33
+
34
+ module.exports = webpackConfig
@@ -0,0 +1,15 @@
1
+ const commonWebpackConfig = require('./commonWebpackConfig')
2
+
3
+ const configureClient = () => {
4
+ const clientConfig = commonWebpackConfig()
5
+
6
+ // server-bundle is special and should ONLY be built by the serverConfig
7
+ // In case this entry is not deleted, a very strange "window" not found
8
+ // error shows referring to window["webpackJsonp"]. That is because the
9
+ // client config is going to try to load chunks.
10
+ delete clientConfig.entry['server-bundle']
11
+
12
+ return clientConfig
13
+ }
14
+
15
+ module.exports = configureClient
@@ -0,0 +1,18 @@
1
+ // Common configuration applying to client and server configuration
2
+
3
+ // const { globalMutableWebpackConfig: baseClientWebpackConfig, merge } = require('shakapacker')
4
+ const { generateWebpackConfig, merge } = require('shakapacker')
5
+ const commonOptions = {
6
+ resolve: {
7
+ extensions: ['.css', '.ts', '.tsx']
8
+ }
9
+ }
10
+
11
+ const ignoreWarningsConfig = {
12
+ ignoreWarnings: [/Module not found: Error: Can't resolve 'react-dom\/client'/],
13
+ };
14
+ // Copy the object using merge b/c the baseClientWebpackConfig and commonOptions are mutable globals
15
+ // const commonWebpackConfig = () => (merge({}, baseClientWebpackConfig, commonOptions))
16
+ const commonWebpackConfig = () => (merge({}, generateWebpackConfig(), commonOptions, ignoreWarningsConfig))
17
+
18
+ module.exports = commonWebpackConfig
@@ -0,0 +1,32 @@
1
+ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
2
+ const path = require('path')
3
+ const { devServer, inliningCss } = require('shakapacker')
4
+
5
+ const webpackConfig = require('./ServerClientOrBoth')
6
+
7
+ const developmentEnvOnly = (clientWebpackConfig, serverWebpackConfig) => {
8
+
9
+ //plugins
10
+ if (inliningCss ) {
11
+ // Note, when this is run, we're building the server and client bundles in separate processes.
12
+ // Thus, this plugin is not applied.
13
+ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
14
+ clientWebpackConfig.plugins.push(
15
+ new ReactRefreshWebpackPlugin({
16
+ overlay:{
17
+ sockPort: devServer.port
18
+ }
19
+ })
20
+ )
21
+ }
22
+
23
+ clientWebpackConfig.plugins.push(
24
+ new ForkTsCheckerWebpackPlugin({
25
+ typescript: {
26
+ configFile: path.resolve(__dirname, '../../tsconfig.json')
27
+ },
28
+ async: false
29
+ })
30
+ )
31
+ }
32
+ module.exports = webpackConfig(developmentEnvOnly)
@@ -0,0 +1,9 @@
1
+ // Below code should get refactored but the current way that rails/webpacker v5
2
+ // does the globals, it's tricky
3
+ const webpackConfig = require('./ServerClientOrBoth')
4
+
5
+ const productionEnvOnly = (_clientWebpackConfig, _serverWebpackConfig) => {
6
+ // place any code here that is for production only
7
+ }
8
+
9
+ module.exports = webpackConfig(productionEnvOnly)
@@ -0,0 +1,116 @@
1
+ const { merge, config } = require('shakapacker')
2
+ const commonWebpackConfig = require('./commonWebpackConfig')
3
+
4
+ const webpack = require('webpack')
5
+
6
+ const configureServer = () => {
7
+ // We need to use "merge" because the clientConfigObject, EVEN after running
8
+ // toWebpackConfig() is a mutable GLOBAL. Thus any changes, like modifying the
9
+ // entry value will result in changing the client config!
10
+ // Using webpack-merge into an empty object avoids this issue.
11
+ const serverWebpackConfig = commonWebpackConfig()
12
+
13
+ // We just want the single server bundle entry
14
+ const serverEntry = {
15
+ 'server-bundle': serverWebpackConfig.entry['server-bundle']
16
+ }
17
+
18
+ if (!serverEntry['server-bundle']) {
19
+ throw new Error('Create a pack with the file name \'server-bundle.js\' containing all the server rendering files')
20
+ }
21
+
22
+ serverWebpackConfig.entry = serverEntry
23
+
24
+ // Remove the mini-css-extract-plugin from the style loaders because
25
+ // the client build will handle exporting CSS.
26
+ // replace file-loader with null-loader
27
+ serverWebpackConfig.module.rules.forEach((loader) => {
28
+ if (loader.use && loader.use.filter) {
29
+ loader.use = loader.use.filter(
30
+ (item) =>
31
+ !(typeof item === 'string' && item.match(/mini-css-extract-plugin/))
32
+ )
33
+ }
34
+ })
35
+
36
+ // No splitting of chunks for a server bundle
37
+ serverWebpackConfig.optimization = {
38
+ minimize: false
39
+ }
40
+ serverWebpackConfig.plugins.unshift(
41
+ new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })
42
+ )
43
+
44
+ // Custom output for the server-bundle that matches the config in
45
+ // config/initializers/react_on_rails.rb
46
+ serverWebpackConfig.output = {
47
+ filename: 'server-bundle.js',
48
+ globalObject: 'this',
49
+ // If using the React on Rails Pro node server renderer, uncomment the next line
50
+ // libraryTarget: 'commonjs2',
51
+ path: config.outputPath,
52
+ publicPath: config.publicPath,
53
+ // https://webpack.js.org/configuration/output/#outputglobalobject
54
+ }
55
+
56
+ // Don't hash the server bundle b/c would conflict with the client manifest
57
+ // And no need for the MiniCssExtractPlugin
58
+ serverWebpackConfig.plugins = serverWebpackConfig.plugins.filter(
59
+ (plugin) =>
60
+ plugin.constructor.name !== 'WebpackAssetsManifest' &&
61
+ plugin.constructor.name !== 'MiniCssExtractPlugin' &&
62
+ plugin.constructor.name !== 'ForkTsCheckerWebpackPlugin'
63
+ )
64
+
65
+ // Configure loader rules for SSR
66
+ // Remove the mini-css-extract-plugin from the style loaders because
67
+ // the client build will handle exporting CSS.
68
+ // replace file-loader with null-loader
69
+ const rules = serverWebpackConfig.module.rules;
70
+ rules.forEach((rule) => {
71
+ if (Array.isArray(rule.use)) {
72
+ // remove the mini-css-extract-plugin and style-loader
73
+ rule.use = rule.use.filter((item) => {
74
+ let testValue;
75
+ if (typeof item === 'string') {
76
+ testValue = item;
77
+ } else if (typeof item.loader === 'string') {
78
+ testValue = item.loader;
79
+ }
80
+ return !(testValue.match(/mini-css-extract-plugin/) || testValue === 'style-loader');
81
+ });
82
+ const cssLoader = rule.use.find((item) => {
83
+ let testValue;
84
+
85
+ if (typeof item === 'string') {
86
+ testValue = item;
87
+ } else if (typeof item.loader === 'string') {
88
+ testValue = item.loader;
89
+ }
90
+
91
+ return testValue.includes('css-loader');
92
+ });
93
+ if (cssLoader && cssLoader.options) {
94
+ cssLoader.options.modules = { exportOnlyLocals: true };
95
+ }
96
+
97
+ // Skip writing image files during SSR by setting emitFile to false
98
+ } else if (rule.use && (rule.use.loader === 'url-loader' || rule.use.loader === 'file-loader')) {
99
+ rule.use.options.emitFile = false;
100
+ }
101
+ });
102
+
103
+ // eval works well for the SSR bundle because it's the fastest and shows
104
+ // lines in the server bundle which is good for debugging SSR
105
+ // The default of cheap-module-source-map is slow and provides poor info.
106
+ serverWebpackConfig.devtool = 'eval'
107
+
108
+ // If using the default 'web', then libraries like Emotion and loadable-components
109
+ // break with SSR. The fix is to use a node renderer and change the target.
110
+ // If using the React on Rails Pro node server renderer, uncomment the next line
111
+ // serverWebpackConfig.target = 'node'
112
+
113
+ return serverWebpackConfig
114
+ }
115
+
116
+ module.exports = configureServer
@@ -0,0 +1,7 @@
1
+ const webpackConfig = require('./ServerClientOrBoth')
2
+
3
+ const testOnly = (_clientWebpackConfig, _serverWebpackConfig) => {
4
+ // place any code here that is for test only
5
+ }
6
+
7
+ module.exports = webpackConfig(testOnly)
@@ -0,0 +1,24 @@
1
+ const { env, webpackConfig } = require('shakapacker')
2
+ const { existsSync } = require('fs')
3
+ const { resolve } = require('path')
4
+
5
+ const envSpecificConfig = () => {
6
+ const path = resolve(__dirname, `${env.nodeEnv}.js`)
7
+ if (existsSync(path)) {
8
+ console.log(`Loading ENV specific webpack configuration file ${path}`)
9
+ return require(path)
10
+ } else {
11
+ return webpackConfig
12
+ }
13
+ }
14
+
15
+ const webpackConfiguration = envSpecificConfig()
16
+
17
+ // To debug the webpack configuration
18
+ // 1. Uncomment debugger line below
19
+ // 2. Run `bin/webpacker --debug-webpacker`
20
+ // 3. Examine the webpackConfiguration variable
21
+ // 4. Consider adding a 'debugger` line to the beginning of this file.
22
+ // debugger
23
+
24
+ module.exports = webpackConfiguration
@@ -0,0 +1,5 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application