shakapacker 6.5.4 → 7.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +1 -0
- data/.github/FUNDING.yml +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +11 -7
- data/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- data/.github/workflows/dummy.yml +21 -0
- data/.github/workflows/generator.yml +37 -0
- data/.github/workflows/jest.yml +2 -2
- data/.github/workflows/js-lint.yml +2 -2
- data/.github/workflows/rubocop.yml +1 -1
- data/.github/workflows/ruby-backward-compatibility.yml +39 -0
- data/.github/workflows/ruby.yml +5 -7
- data/.gitignore +6 -3
- data/.rspec +1 -0
- data/CHANGELOG.md +83 -2
- data/CONTRIBUTING.md +84 -18
- data/Gemfile.development_dependencies +3 -1
- data/README.md +159 -97
- data/Rakefile +46 -6
- data/config/shakapacker.yml +1 -0
- data/docs/deployment.md +11 -10
- data/docs/{developing_webpacker.md → developing_shakapacker.md} +5 -5
- data/docs/react.md +10 -6
- data/docs/style_loader_vs_mini_css.md +3 -3
- data/docs/troubleshooting.md +22 -18
- data/docs/using_esbuild_loader.md +5 -3
- data/docs/using_swc_loader.md +2 -2
- data/docs/v6_upgrade.md +9 -13
- data/docs/v7_upgrade.md +59 -0
- data/gemfiles/Gemfile-rails-edge +1 -1
- data/gemfiles/Gemfile-rails.6.0.x +1 -1
- data/gemfiles/Gemfile-rails.6.1.x +1 -1
- data/gemfiles/Gemfile-rails.7.0.x +1 -1
- data/lib/install/bin/shakapacker +13 -0
- data/lib/install/bin/shakapacker-dev-server +13 -0
- data/lib/install/binstubs.rb +3 -1
- data/lib/install/config/{webpacker.yml → shakapacker.yml} +28 -11
- data/lib/install/config/webpack/webpack.config.js +3 -2
- data/lib/install/template.rb +51 -34
- data/lib/{webpacker → shakapacker}/base_strategy.rb +2 -2
- data/lib/{webpacker → shakapacker}/commands.rb +4 -4
- data/lib/{webpacker → shakapacker}/compiler.rb +43 -15
- data/lib/{webpacker → shakapacker}/compiler_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/configuration.rb +52 -21
- data/lib/shakapacker/deprecation_helper.rb +87 -0
- data/lib/{webpacker → shakapacker}/dev_server.rb +27 -4
- data/lib/{webpacker → shakapacker}/dev_server_proxy.rb +4 -4
- data/lib/shakapacker/dev_server_runner.rb +104 -0
- data/lib/{webpacker → shakapacker}/digest_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/env.rb +8 -8
- data/lib/{webpacker → shakapacker}/helper.rb +40 -29
- data/lib/shakapacker/instance.rb +50 -0
- data/lib/{webpacker → shakapacker}/manifest.rb +14 -14
- data/lib/{webpacker → shakapacker}/mtime_strategy.rb +5 -5
- data/lib/shakapacker/railtie.rb +70 -0
- data/lib/shakapacker/runner.rb +28 -0
- data/lib/shakapacker/utils/version_syntax_converter.rb +2 -2
- data/lib/{webpacker → shakapacker}/version.rb +2 -2
- data/lib/{webpacker → shakapacker}/version_checker.rb +8 -8
- data/lib/shakapacker/webpack_runner.rb +67 -0
- data/lib/shakapacker.rb +51 -1
- data/lib/tasks/shakapacker/binstubs.rake +15 -0
- data/lib/tasks/shakapacker/check_binstubs.rake +29 -0
- data/lib/tasks/shakapacker/check_node.rake +31 -0
- data/lib/tasks/shakapacker/check_yarn.rake +33 -0
- data/lib/tasks/shakapacker/clean.rake +23 -0
- data/lib/tasks/shakapacker/clobber.rake +18 -0
- data/lib/tasks/shakapacker/compile.rake +28 -0
- data/lib/tasks/shakapacker/info.rake +21 -0
- data/lib/tasks/shakapacker/install.rake +17 -0
- data/lib/tasks/shakapacker/verify_config.rake +12 -0
- data/lib/tasks/shakapacker/verify_install.rake +4 -0
- data/lib/tasks/shakapacker/yarn_install.rake +24 -0
- data/lib/tasks/shakapacker.rake +18 -0
- data/lib/tasks/webpacker/binstubs.rake +5 -11
- data/lib/tasks/webpacker/check_binstubs.rake +6 -9
- data/lib/tasks/webpacker/check_node.rake +5 -27
- data/lib/tasks/webpacker/check_yarn.rake +5 -29
- data/lib/tasks/webpacker/clean.rake +5 -19
- data/lib/tasks/webpacker/clobber.rake +6 -13
- data/lib/tasks/webpacker/compile.rake +5 -38
- data/lib/tasks/webpacker/info.rake +5 -17
- data/lib/tasks/webpacker/install.rake +5 -13
- data/lib/tasks/webpacker/verify_config.rake +6 -11
- data/lib/tasks/webpacker/verify_install.rake +7 -2
- data/lib/tasks/webpacker/yarn_install.rake +5 -20
- data/lib/tasks/webpacker.rake +15 -13
- data/lib/webpacker/dev_server_runner.rb +9 -96
- data/lib/webpacker/webpack_runner.rb +9 -58
- data/lib/webpacker.rb +3 -47
- data/package/__tests__/config-bc.js +27 -0
- data/package/__tests__/config.js +6 -5
- data/package/__tests__/dev_server-bc.js +46 -0
- data/package/__tests__/dev_server.js +9 -8
- data/package/__tests__/development-bc.js +66 -0
- data/package/__tests__/development.js +36 -5
- data/package/__tests__/env-bc.js +59 -0
- data/package/__tests__/env.js +3 -2
- data/package/__tests__/index-bc.js +22 -0
- data/package/__tests__/index.js +13 -0
- data/package/__tests__/production-bc.js +51 -0
- data/package/__tests__/production.js +25 -3
- data/package/__tests__/staging-bc.js +53 -0
- data/package/__tests__/staging.js +27 -4
- data/package/__tests__/test-bc.js +43 -0
- data/package/__tests__/test.js +22 -4
- data/package/babel/preset.js +1 -4
- data/package/config.js +25 -7
- data/package/dev_server.js +7 -4
- data/package/env.js +22 -3
- data/package/environments/__tests__/base-bc.js +107 -0
- data/package/environments/__tests__/base.js +15 -15
- data/package/environments/__tests__/development.js +53 -0
- data/package/environments/__tests__/production.js +92 -0
- data/package/environments/base.js +5 -4
- data/package/environments/development.js +4 -46
- data/package/environments/production.js +10 -1
- data/package/index.js +35 -5
- data/package/rules/__tests__/__utils__/webpack.js +50 -0
- data/package/rules/__tests__/babel.js +63 -0
- data/package/rules/__tests__/esbuild.js +64 -0
- data/package/rules/__tests__/file.js +27 -0
- data/package/rules/__tests__/index.js +0 -4
- data/package/rules/__tests__/swc.js +63 -0
- data/package/rules/babel.js +13 -24
- data/package/rules/esbuild.js +2 -13
- data/package/rules/file.js +2 -2
- data/package/rules/jscommon.js +26 -0
- data/package/rules/swc.js +2 -13
- data/package/utils/configPath.js +19 -0
- data/package/utils/defaultConfigPath.js +2 -0
- data/package/utils/get_style_rule.js +5 -2
- data/package/utils/helpers.js +25 -2
- data/package/utils/inliningCss.js +7 -0
- data/package/utils/snakeToCamelCase +7 -0
- data/package/webpackDevServerConfig.js +68 -0
- data/package.json +11 -5
- data/{webpacker.gemspec → shakapacker.gemspec} +3 -3
- data/spec/backward_compatibility_specs/command_spec.rb +116 -0
- data/spec/backward_compatibility_specs/compiler_spec.rb +59 -0
- data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +22 -0
- data/spec/backward_compatibility_specs/configuration_spec.rb +286 -0
- data/{test/dev_server_runner_test.rb → spec/backward_compatibility_specs/dev_server_runner_spec.rb} +37 -39
- data/spec/backward_compatibility_specs/dev_server_spec.rb +47 -0
- data/spec/backward_compatibility_specs/digest_strategy_spec.rb +35 -0
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +44 -0
- data/spec/backward_compatibility_specs/env_spec.rb +23 -0
- data/spec/backward_compatibility_specs/helper_spec.rb +243 -0
- data/spec/backward_compatibility_specs/instance_spec.rb +31 -0
- data/spec/backward_compatibility_specs/manifest_spec.rb +100 -0
- data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +55 -0
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +37 -0
- data/spec/backward_compatibility_specs/spec_helper_initializer.rb +24 -0
- data/{test/webpack_runner_test.rb → spec/backward_compatibility_specs/webpack_runner_spec.rb} +15 -16
- data/spec/backward_compatibility_specs/webpacker_spec.rb +41 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +2 -0
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/application.js +1 -1
- data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +11 -0
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker.yml +1 -1
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_css_extract_ignore_order_warnings.yml +1 -1
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_defaults_fallback.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +7 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_other_location.yml +85 -0
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_public_root.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/package.json +13 -0
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/public/packs/manifest.json +8 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +1 -0
- data/spec/dummy/.browserslistrc +1 -0
- data/spec/dummy/.gitignore +20 -0
- data/spec/dummy/.prettierrc.yaml +4 -0
- data/spec/dummy/Gemfile +63 -0
- data/spec/dummy/Procfile.dev +5 -0
- data/spec/dummy/Procfile.dev-static +9 -0
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/hello_world_controller.rb +9 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/Globals.d.ts +3 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +25 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx +47 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorldServer.tsx +5 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/logo.svg +7 -0
- data/spec/dummy/app/javascript/packs/application.js +17 -0
- data/spec/dummy/app/javascript/packs/hello-world-bundle.ts +8 -0
- data/spec/dummy/app/javascript/packs/server-bundle.ts +8 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/hello_world/index.html.erb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/hello_world.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/babel.config.js +30 -0
- data/spec/dummy/bin/bundle +114 -0
- data/spec/dummy/bin/dev +30 -0
- data/spec/dummy/bin/dev-static +30 -0
- data/spec/dummy/bin/rails +9 -0
- data/spec/dummy/bin/rake +9 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/bin/shakapacker +13 -0
- data/spec/dummy/bin/shakapacker-dev-server +13 -0
- data/spec/dummy/bin/spring +17 -0
- data/spec/dummy/bin/yarn +18 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/credentials.yml.enc +1 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +106 -0
- data/spec/dummy/config/environments/test.rb +49 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/react_on_rails.rb +58 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config/shakapacker.yml +62 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config/webpack/ServerClientOrBoth.js +34 -0
- data/spec/dummy/config/webpack/clientWebpackConfig.js +15 -0
- data/spec/dummy/config/webpack/commonWebpackConfig.js +18 -0
- data/spec/dummy/config/webpack/development.js +32 -0
- data/spec/dummy/config/webpack/production.js +9 -0
- data/spec/dummy/config/webpack/serverWebpackConfig.js +116 -0
- data/spec/dummy/config/webpack/test.js +7 -0
- data/spec/dummy/config/webpack/webpack.config.js +24 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/package.json +44 -0
- data/spec/dummy/postcss.config.js +12 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +1 -0
- data/spec/dummy/spec/rails_helper.rb +118 -0
- data/spec/dummy/spec/spec_helper.rb +96 -0
- data/spec/dummy/spec/system/hello_world_spec.rb +19 -0
- data/spec/dummy/tsconfig.json +21 -0
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/dummy/yarn.lock +4697 -0
- data/spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb +4 -0
- data/spec/generator_specs/e2e_template/files/app/javascript/components/App.js +12 -0
- data/spec/generator_specs/e2e_template/files/app/javascript/packs/application.js +10 -0
- data/spec/generator_specs/e2e_template/files/app/views/home/index.html.erb +2 -0
- data/spec/generator_specs/e2e_template/files/app/views/layouts/application.html.erb +17 -0
- data/spec/generator_specs/e2e_template/files/config/routes.rb +3 -0
- data/spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb +13 -0
- data/spec/generator_specs/e2e_template/template.rb +21 -0
- data/spec/generator_specs/generator_spec.rb +169 -0
- data/{test → spec}/mounted_app/test/dummy/config/application.rb +1 -1
- data/{test → spec}/mounted_app/test/dummy/config/webpacker.yml +11 -5
- data/spec/shakapacker/command_spec.rb +116 -0
- data/spec/shakapacker/compiler_spec.rb +59 -0
- data/spec/shakapacker/compiler_strategy_spec.rb +22 -0
- data/spec/shakapacker/configuration_spec.rb +323 -0
- data/spec/shakapacker/dev_server_runner_spec.rb +72 -0
- data/spec/shakapacker/dev_server_spec.rb +133 -0
- data/spec/shakapacker/digest_strategy_spec.rb +35 -0
- data/spec/shakapacker/engine_rake_tasks_spec.rb +43 -0
- data/spec/shakapacker/env_spec.rb +23 -0
- data/spec/shakapacker/helper_spec.rb +243 -0
- data/spec/shakapacker/instance_spec.rb +31 -0
- data/spec/shakapacker/manifest_spec.rb +100 -0
- data/spec/shakapacker/mtime_strategy_spec.rb +55 -0
- data/spec/shakapacker/rake_tasks_spec.rb +93 -0
- data/spec/shakapacker/shakapacker_spec.rb +41 -0
- data/spec/shakapacker/spec_helper_initializer.rb +24 -0
- data/spec/shakapacker/test_app/.gitignore +2 -0
- data/spec/shakapacker/test_app/Rakefile +3 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/application.js +10 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/generated/something.js +2 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.css +4 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.js +4 -0
- data/{test/test_app/bin/webpacker-dev-server → spec/shakapacker/test_app/bin/shakapacker} +3 -3
- data/{test/test_app/bin/webpacker → spec/shakapacker/test_app/bin/shakapacker-dev-server} +3 -3
- data/{test → spec/shakapacker}/test_app/config/application.rb +1 -1
- data/spec/shakapacker/test_app/config/environment.rb +4 -0
- data/spec/shakapacker/test_app/config/initializers/inspect_autoload_paths.rb +1 -0
- data/spec/shakapacker/test_app/config/shakapacker.yml +82 -0
- data/spec/shakapacker/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +84 -0
- data/spec/shakapacker/test_app/config/shakapacker_defaults_fallback.yml +11 -0
- data/{test/test_app/config/webpacker_other_location.yml → spec/shakapacker/test_app/config/shakapacker_manifest_path.yml} +6 -5
- data/spec/shakapacker/test_app/config/shakapacker_nested_entries.yml +83 -0
- data/spec/shakapacker/test_app/config/shakapacker_no_precompile.yml +7 -0
- data/spec/shakapacker/test_app/config/shakapacker_other_location.yml +85 -0
- data/spec/shakapacker/test_app/config/shakapacker_public_root.yml +18 -0
- data/spec/shakapacker/test_app/config/webpack/webpack.config.js +0 -0
- data/spec/shakapacker/test_app/config.ru +5 -0
- data/spec/shakapacker/test_app/public/packs/manifest.json +58 -0
- data/spec/shakapacker/test_app/some.config.js +0 -0
- data/spec/shakapacker/test_app/yarn.lock +11 -0
- data/spec/shakapacker/version_checker_spec.rb +951 -0
- data/spec/shakapacker/webpack_runner_spec.rb +55 -0
- data/spec/spec_helper.rb +98 -0
- data/yarn.lock +846 -844
- metadata +314 -213
- data/.github/ISSUE_TEMPLATE/feature-request.md +0 -18
- data/config/webpacker.yml +0 -1
- data/gemfiles/Gemfile-rails.5.2.x +0 -9
- data/lib/tasks/yarn.rake +0 -44
- data/lib/webpacker/instance.rb +0 -45
- data/lib/webpacker/railtie.rb +0 -70
- data/lib/webpacker/runner.rb +0 -23
- data/package/configPath.js +0 -3
- data/package/inliningCss.js +0 -7
- data/test/command_test.rb +0 -109
- data/test/compiler_strategy_test.rb +0 -27
- data/test/compiler_test.rb +0 -60
- data/test/configuration_test.rb +0 -186
- data/test/dev_server_test.rb +0 -47
- data/test/digest_strategy_test.rb +0 -33
- data/test/engine_rake_tasks_test.rb +0 -39
- data/test/env_test.rb +0 -23
- data/test/helper_test.rb +0 -248
- data/test/manifest_test.rb +0 -89
- data/test/mtime_strategy_test.rb +0 -42
- data/test/rake_tasks_test.rb +0 -37
- data/test/test_app/config/webpacker_no_precompile.yml +0 -7
- data/test/test_helper.rb +0 -33
- data/test/version_checker_test.rb +0 -826
- data/test/webpacker_test.rb +0 -49
- /data/{test/mounted_app/test/dummy → spec/backward_compatibility_specs/webpacker_test_app}/Rakefile +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/generated/something.js +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.css +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.js +0 -0
- /data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker-dev-server +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/environment.rb +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/initializers/inspect_autoload_paths.rb +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpack/webpack.config.js +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_manifest_path.yml +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_nested_entries.yml +0 -0
- /data/{test/mounted_app/test/dummy → spec/backward_compatibility_specs/webpacker_test_app}/config.ru +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/some.config.js +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/yarn.lock +0 -0
- /data/{test → spec}/fixtures/beta_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/beta_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/beta_package.json +0 -0
- /data/{test → spec}/fixtures/beta_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/beta_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/git_url_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/git_url_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/git_url_package.json +0 -0
- /data/{test → spec}/fixtures/git_url_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/git_url_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/github_url_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/github_url_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/github_url_package.json +0 -0
- /data/{test → spec}/fixtures/github_url_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/github_url_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/relative_path_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/relative_path_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/relative_path_package.json +0 -0
- /data/{test → spec}/fixtures/relative_path_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/relative_path_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/semver_caret_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/semver_caret_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/semver_caret_package.json +0 -0
- /data/{test → spec}/fixtures/semver_caret_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/semver_caret_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/semver_exact_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/semver_exact_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/semver_exact_package.json +0 -0
- /data/{test → spec}/fixtures/semver_exact_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/semver_exact_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/semver_tilde_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/semver_tilde_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/semver_tilde_package.json +0 -0
- /data/{test → spec}/fixtures/semver_tilde_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/semver_tilde_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/without_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/without_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/without_package.json +0 -0
- /data/{test → spec}/fixtures/without_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/without_yarn.v2.lock +0 -0
- /data/{test → spec}/mounted_app/Rakefile +0 -0
- /data/{test/test_app → spec/mounted_app/test/dummy}/Rakefile +0 -0
- /data/{test → spec}/mounted_app/test/dummy/bin/rails +0 -0
- /data/{test → spec}/mounted_app/test/dummy/bin/rake +0 -0
- /data/{test → spec}/mounted_app/test/dummy/config/environment.rb +0 -0
- /data/{test/test_app → spec/mounted_app/test/dummy}/config.ru +0 -0
- /data/{test → spec}/mounted_app/test/dummy/package.json +0 -0
- /data/{test → spec/shakapacker}/test_app/package.json +0 -0
@@ -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,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,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,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,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
7
|
+
# Character.create(name: 'Luke', movie: movies.first)
|
File without changes
|
File without changes
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"engines": {
|
3
|
+
"node": ">=12.13.0",
|
4
|
+
"yarn": ">=1 <4"
|
5
|
+
},
|
6
|
+
"dependencies": {
|
7
|
+
"@babel/core": "^7.18.2",
|
8
|
+
"@babel/plugin-transform-runtime": "^7.18.2",
|
9
|
+
"@babel/preset-env": "^7.18.2",
|
10
|
+
"@babel/preset-react": "^7.18.6",
|
11
|
+
"@babel/preset-typescript": "^7.17.12",
|
12
|
+
"@babel/runtime": "^7.18.3",
|
13
|
+
"@types/react": "^16.14.26",
|
14
|
+
"@types/react-dom": "^16.9.16",
|
15
|
+
"babel-loader": "^8.2.5",
|
16
|
+
"babel-plugin-macros": "^3.1.0",
|
17
|
+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
18
|
+
"compression-webpack-plugin": "^9.2.0",
|
19
|
+
"css-loader": "^6.7.3",
|
20
|
+
"css-minimizer-webpack-plugin": "^4.2.2",
|
21
|
+
"mini-css-extract-plugin": "^2.7.2",
|
22
|
+
"pnp-webpack-plugin": "^1.7.0",
|
23
|
+
"prop-types": "^15.8.1",
|
24
|
+
"react": "^18.2.0",
|
25
|
+
"react-dom": "^18.2.0",
|
26
|
+
"react-on-rails": "13.3.2",
|
27
|
+
"shakapacker": "file:.yalc/shakapacker",
|
28
|
+
"style-loader": "^3.3.1",
|
29
|
+
"terser-webpack-plugin": "^5.3.3",
|
30
|
+
"typescript": "^4.7.3",
|
31
|
+
"webpack": "^5.73.0",
|
32
|
+
"webpack-assets-manifest": "^5.1.0",
|
33
|
+
"webpack-cli": "^4.9.2",
|
34
|
+
"webpack-merge": "^5.8.0",
|
35
|
+
"webpack-sources": "^3.2.3"
|
36
|
+
},
|
37
|
+
"devDependencies": {
|
38
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
39
|
+
"fork-ts-checker-webpack-plugin": "^6.5.2",
|
40
|
+
"react-refresh": "^0.14.0",
|
41
|
+
"webpack-dev-server": "^4.9.2"
|
42
|
+
},
|
43
|
+
"packageManager": "yarn@3.2.1"
|
44
|
+
}
|