shakapacker 6.6.0 → 7.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +4 -8
- 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 +2 -6
- data/.gitignore +3 -0
- data/CHANGELOG.md +48 -4
- data/CONTRIBUTING.md +78 -22
- data/Gemfile.development_dependencies +1 -1
- data/README.md +115 -88
- data/Rakefile +46 -5
- 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 +2 -2
- 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 +2 -2
- data/docs/v7_upgrade.md +56 -0
- 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} +13 -8
- data/lib/install/config/webpack/webpack.config.js +3 -2
- data/lib/install/template.rb +30 -18
- 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 +20 -20
- data/lib/{webpacker → shakapacker}/instance.rb +13 -10
- 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 +26 -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 -33
- 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.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 +13 -13
- data/package/environments/base.js +1 -1
- data/package/environments/development.js +4 -46
- data/package/environments/production.js +1 -1
- data/package/index.js +27 -4
- data/package/rules/__tests__/__utils__/webpack.js +1 -1
- data/package/rules/__tests__/file.js +27 -0
- data/package/rules/__tests__/swc.js +1 -2
- data/package/rules/file.js +2 -2
- 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 +2 -2
- data/{webpacker.gemspec → shakapacker.gemspec} +3 -3
- data/spec/{command_spec.rb → backward_compatibility_specs/command_spec.rb} +2 -0
- data/spec/{compiler_spec.rb → backward_compatibility_specs/compiler_spec.rb} +6 -4
- data/spec/{compiler_strategy_spec.rb → backward_compatibility_specs/compiler_strategy_spec.rb} +2 -0
- data/spec/{configuration_spec.rb → backward_compatibility_specs/configuration_spec.rb} +25 -20
- data/spec/{dev_server_runner_spec.rb → backward_compatibility_specs/dev_server_runner_spec.rb} +10 -2
- data/spec/{dev_server_spec.rb → backward_compatibility_specs/dev_server_spec.rb} +4 -2
- data/spec/{digest_strategy_spec.rb → backward_compatibility_specs/digest_strategy_spec.rb} +2 -0
- data/spec/{engine_rake_tasks_spec.rb → backward_compatibility_specs/engine_rake_tasks_spec.rb} +12 -15
- data/spec/{env_spec.rb → backward_compatibility_specs/env_spec.rb} +3 -1
- data/spec/{helper_spec.rb → backward_compatibility_specs/helper_spec.rb} +2 -0
- data/spec/backward_compatibility_specs/instance_spec.rb +31 -0
- data/spec/{manifest_spec.rb → backward_compatibility_specs/manifest_spec.rb} +4 -2
- data/spec/{mtime_strategy_spec.rb → backward_compatibility_specs/mtime_strategy_spec.rb} +2 -0
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +37 -0
- data/spec/backward_compatibility_specs/spec_helper_initializer.rb +24 -0
- data/spec/{webpack_runner_spec.rb → backward_compatibility_specs/webpack_runner_spec.rb} +3 -1
- data/spec/{webpacker_spec.rb → backward_compatibility_specs/webpacker_spec.rb} +3 -23
- data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +2 -0
- data/spec/{test_app → 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/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_css_extract_ignore_order_warnings.yml +1 -1
- data/spec/{test_app → 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/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_other_location.yml +1 -1
- data/spec/{test_app → 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/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/spec/mounted_app/test/dummy/config/application.rb +1 -1
- data/spec/mounted_app/test/dummy/config/webpacker.yml +3 -3
- 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/spec/{test_app/bin/webpacker-dev-server → shakapacker/test_app/bin/shakapacker} +3 -3
- data/spec/{test_app/bin/webpacker → shakapacker/test_app/bin/shakapacker-dev-server} +3 -3
- data/spec/{test_app → 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/spec/shakapacker/test_app/config/shakapacker_manifest_path.yml +80 -0
- 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/{version_checker_spec.rb → shakapacker/version_checker_spec.rb} +25 -24
- data/spec/shakapacker/webpack_runner_spec.rb +55 -0
- data/spec/spec_helper.rb +0 -25
- metadata +253 -72
- data/config/webpacker.yml +0 -1
- data/gemfiles/Gemfile-rails.5.2.x +0 -9
- 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/spec/rake_tasks_spec.rb +0 -32
- data/spec/test_app/config/webpacker_no_precompile.yml +0 -7
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/Rakefile +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/generated/something.js +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.css +0 -0
- /data/spec/{test_app → 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/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/environment.rb +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/initializers/inspect_autoload_paths.rb +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpack/webpack.config.js +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_manifest_path.yml +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_nested_entries.yml +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config.ru +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/public/packs/manifest.json +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/some.config.js +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/yarn.lock +0 -0
- /data/spec/{test_app → shakapacker/test_app}/package.json +0 -0
@@ -1,16 +1,17 @@
|
|
1
1
|
require "open3"
|
2
|
-
require "
|
2
|
+
require "shakapacker/compiler_strategy"
|
3
|
+
require "fileutils"
|
3
4
|
|
4
|
-
class
|
5
|
+
class Shakapacker::Compiler
|
5
6
|
# Additional environment variables that the compiler is being run with
|
6
|
-
#
|
7
|
+
# Shakapacker::Compiler.env['FRONTEND_API_KEY'] = 'your_secret_key'
|
7
8
|
cattr_accessor(:env) { {} }
|
8
9
|
|
9
|
-
delegate :config, :logger, :strategy, to: :
|
10
|
+
delegate :config, :logger, :strategy, to: :instance
|
10
11
|
delegate :fresh?, :stale?, :after_compile_hook, to: :strategy
|
11
12
|
|
12
|
-
def initialize(
|
13
|
-
@
|
13
|
+
def initialize(instance)
|
14
|
+
@instance = instance
|
14
15
|
end
|
15
16
|
|
16
17
|
def compile
|
@@ -32,7 +33,7 @@ class Webpacker::Compiler
|
|
32
33
|
end
|
33
34
|
|
34
35
|
private
|
35
|
-
attr_reader :
|
36
|
+
attr_reader :instance
|
36
37
|
|
37
38
|
def acquire_ipc_lock
|
38
39
|
open_lock_file do |lf|
|
@@ -55,15 +56,24 @@ class Webpacker::Compiler
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def open_lock_file
|
58
|
-
|
59
|
-
|
59
|
+
create_lock_file_dir unless File.exist?(lock_file_path)
|
60
|
+
|
61
|
+
File.open(lock_file_path, File::CREAT) do |lf|
|
60
62
|
return yield lf
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
66
|
+
def create_lock_file_dir
|
67
|
+
dirname = File.dirname(lock_file_path)
|
68
|
+
FileUtils.mkdir_p(dirname)
|
69
|
+
end
|
70
|
+
|
71
|
+
def lock_file_path
|
72
|
+
config.root_path.join("tmp/shakapacker.lock")
|
73
|
+
end
|
74
|
+
|
64
75
|
def optionalRubyRunner
|
65
|
-
|
66
|
-
first_line = File.readlines(bin_webpack_path).first.chomp
|
76
|
+
first_line = File.readlines(bin_shakapacker_path).first.chomp
|
67
77
|
/ruby/.match?(first_line) ? RbConfig.ruby : ""
|
68
78
|
end
|
69
79
|
|
@@ -72,7 +82,7 @@ class Webpacker::Compiler
|
|
72
82
|
|
73
83
|
stdout, stderr, status = Open3.capture3(
|
74
84
|
webpack_env,
|
75
|
-
"#{optionalRubyRunner}
|
85
|
+
"#{optionalRubyRunner} #{bin_shakapacker_path}",
|
76
86
|
chdir: File.expand_path(config.root_path)
|
77
87
|
)
|
78
88
|
|
@@ -94,8 +104,26 @@ class Webpacker::Compiler
|
|
94
104
|
def webpack_env
|
95
105
|
return env unless defined?(ActionController::Base)
|
96
106
|
|
97
|
-
|
98
|
-
|
99
|
-
|
107
|
+
Shakapacker.set_shakapacker_env_variables_for_backward_compatibility
|
108
|
+
|
109
|
+
env.merge("SHAKAPACKER_ASSET_HOST" => ENV.fetch("SHAKAPACKER_ASSET_HOST", ActionController::Base.helpers.compute_asset_host),
|
110
|
+
"SHAKAPACKER_RELATIVE_URL_ROOT" => ENV.fetch("SHAKAPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root),
|
111
|
+
"SHAKAPACKER_CONFIG" => instance.config_path.to_s)
|
112
|
+
end
|
113
|
+
|
114
|
+
def bin_shakapacker_path
|
115
|
+
if File.exist?(config.root_path.join("bin/shakapacker"))
|
116
|
+
config.root_path.join("bin/shakapacker")
|
117
|
+
elsif File.exist?(config.root_path.join("bin/webpacker"))
|
118
|
+
Shakapacker.puts_deprecation_message(
|
119
|
+
Shakapacker.short_deprecation_message(
|
120
|
+
"bin/webpacker",
|
121
|
+
"bin/shakapacker"
|
122
|
+
)
|
123
|
+
)
|
124
|
+
config.root_path.join("bin/webpacker")
|
125
|
+
else
|
126
|
+
config.root_path.join("bin/shakapacker")
|
127
|
+
end
|
100
128
|
end
|
101
129
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
1
|
+
require "shakapacker/mtime_strategy"
|
2
|
+
require "shakapacker/digest_strategy"
|
3
3
|
|
4
|
-
module
|
4
|
+
module Shakapacker
|
5
5
|
class CompilerStrategy
|
6
6
|
def self.from_config
|
7
|
-
strategy_from_config =
|
7
|
+
strategy_from_config = Shakapacker.config.compiler_strategy
|
8
8
|
|
9
9
|
case strategy_from_config
|
10
10
|
when "mtime"
|
11
|
-
|
11
|
+
Shakapacker::MtimeStrategy.new
|
12
12
|
when "digest"
|
13
|
-
|
13
|
+
Shakapacker::DigestStrategy.new
|
14
14
|
else
|
15
15
|
raise "Unknown strategy '#{strategy_from_config}'. " \
|
16
16
|
"Available options are 'mtime' and 'digest'."
|
@@ -2,7 +2,7 @@ require "yaml"
|
|
2
2
|
require "active_support/core_ext/hash/keys"
|
3
3
|
require "active_support/core_ext/hash/indifferent_access"
|
4
4
|
|
5
|
-
class
|
5
|
+
class Shakapacker::Configuration
|
6
6
|
class << self
|
7
7
|
attr_accessor :installing
|
8
8
|
end
|
@@ -11,8 +11,11 @@ class Webpacker::Configuration
|
|
11
11
|
|
12
12
|
def initialize(root_path:, config_path:, env:)
|
13
13
|
@root_path = root_path
|
14
|
-
@config_path = config_path
|
15
14
|
@env = env
|
15
|
+
|
16
|
+
# For backward compatibility
|
17
|
+
Shakapacker.set_shakapacker_env_variables_for_backward_compatibility
|
18
|
+
@config_path = Pathname.new(ENV["SHAKAPACKER_CONFIG"] || config_path)
|
16
19
|
end
|
17
20
|
|
18
21
|
def dev_server
|
@@ -31,13 +34,24 @@ class Webpacker::Configuration
|
|
31
34
|
fetch(:ensure_consistent_versioning)
|
32
35
|
end
|
33
36
|
|
34
|
-
def
|
37
|
+
def shakapacker_precompile?
|
35
38
|
# ENV of false takes precedence
|
36
|
-
return false if %w(no false n f).include?(ENV["
|
37
|
-
return true if %w(yes true y t).include?(ENV["
|
39
|
+
return false if %w(no false n f).include?(ENV["SHAKAPACKER_PRECOMPILE"])
|
40
|
+
return true if %w(yes true y t).include?(ENV["SHAKAPACKER_PRECOMPILE"])
|
38
41
|
|
39
42
|
return false unless config_path.exist?
|
40
|
-
fetch(:
|
43
|
+
fetch(:shakapacker_precompile)
|
44
|
+
end
|
45
|
+
|
46
|
+
def webpacker_precompile?
|
47
|
+
Shakapacker.puts_deprecation_message(
|
48
|
+
Shakapacker.short_deprecation_message(
|
49
|
+
"webpacker_precompile?",
|
50
|
+
"shakapacker_precompile?"
|
51
|
+
)
|
52
|
+
)
|
53
|
+
|
54
|
+
shakapacker_precompile?
|
41
55
|
end
|
42
56
|
|
43
57
|
def source_path
|
@@ -49,7 +63,7 @@ class Webpacker::Configuration
|
|
49
63
|
end
|
50
64
|
|
51
65
|
def source_entry_path
|
52
|
-
source_path.join(fetch(:source_entry_path))
|
66
|
+
source_path.join(relative_path(fetch(:source_entry_path)))
|
53
67
|
end
|
54
68
|
|
55
69
|
def manifest_path
|
@@ -80,14 +94,6 @@ class Webpacker::Configuration
|
|
80
94
|
root_path.join(fetch(:cache_path))
|
81
95
|
end
|
82
96
|
|
83
|
-
def check_yarn_integrity=(value)
|
84
|
-
warn <<~EOS
|
85
|
-
Webpacker::Configuration#check_yarn_integrity=(value) is obsolete. The integrity
|
86
|
-
check has been removed from Webpacker (https://github.com/rails/webpacker/pull/2518)
|
87
|
-
so changing this setting will have no effect.
|
88
|
-
EOS
|
89
|
-
end
|
90
|
-
|
91
97
|
def webpack_compile_output?
|
92
98
|
fetch(:webpack_compile_output)
|
93
99
|
end
|
@@ -97,7 +103,17 @@ class Webpacker::Configuration
|
|
97
103
|
end
|
98
104
|
|
99
105
|
def fetch(key)
|
100
|
-
data.fetch(key, defaults[key])
|
106
|
+
return data.fetch(key, defaults[key]) unless key == :webpacker_precompile
|
107
|
+
|
108
|
+
# for backward compatibility
|
109
|
+
Shakapacker.puts_deprecation_message(
|
110
|
+
Shakapacker.short_deprecation_message(
|
111
|
+
"webpacker_precompile",
|
112
|
+
"shakapacker_precompile"
|
113
|
+
)
|
114
|
+
)
|
115
|
+
|
116
|
+
data.fetch(key, defaults[:shakapacker_precompile])
|
101
117
|
end
|
102
118
|
|
103
119
|
private
|
@@ -111,13 +127,22 @@ class Webpacker::Configuration
|
|
111
127
|
rescue ArgumentError
|
112
128
|
YAML.load_file(config_path.to_s)
|
113
129
|
end
|
114
|
-
config[env].deep_symbolize_keys
|
130
|
+
symbolized_config = config[env].deep_symbolize_keys
|
131
|
+
|
132
|
+
# For backward compatibility
|
133
|
+
if symbolized_config.key?(:shakapacker_precompile) && !symbolized_config.key?(:webpacker_precompile)
|
134
|
+
symbolized_config[:webpacker_precompile] = symbolized_config[:shakapacker_precompile]
|
135
|
+
elsif !symbolized_config.key?(:shakapacker_precompile) && symbolized_config.key?(:webpacker_precompile)
|
136
|
+
symbolized_config[:shakapacker_precompile] = symbolized_config[:webpacker_precompile]
|
137
|
+
end
|
138
|
+
|
139
|
+
return symbolized_config
|
115
140
|
rescue Errno::ENOENT => e
|
116
141
|
if self.class.installing
|
117
142
|
{}
|
118
143
|
else
|
119
|
-
raise "
|
120
|
-
"Please run rails
|
144
|
+
raise "Shakapacker configuration file not found #{config_path}. " \
|
145
|
+
"Please run rails shakapacker:install " \
|
121
146
|
"Error: #{e.message}"
|
122
147
|
end
|
123
148
|
rescue Psych::SyntaxError => e
|
@@ -128,13 +153,19 @@ class Webpacker::Configuration
|
|
128
153
|
|
129
154
|
def defaults
|
130
155
|
@defaults ||= begin
|
131
|
-
path = File.expand_path("../../install/config/
|
156
|
+
path = File.expand_path("../../install/config/shakapacker.yml", __FILE__)
|
132
157
|
config = begin
|
133
158
|
YAML.load_file(path, aliases: true)
|
134
159
|
rescue ArgumentError
|
135
160
|
YAML.load_file(path)
|
136
161
|
end
|
137
|
-
HashWithIndifferentAccess.new(config[env] || config[
|
162
|
+
HashWithIndifferentAccess.new(config[env] || config[Shakapacker::DEFAULT_ENV])
|
138
163
|
end
|
139
164
|
end
|
165
|
+
|
166
|
+
def relative_path(path)
|
167
|
+
return ".#{path}" if path.start_with?("/")
|
168
|
+
|
169
|
+
path
|
170
|
+
end
|
140
171
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Shakapacker
|
4
|
+
DEPRECATION_GUIDE_URL = "https://github.com/shakacode/shakapacker/docs/v7_upgrade.md"
|
5
|
+
DEPRECATION_MESSAGE = <<~MSG
|
6
|
+
DEPRECATION NOTICE:
|
7
|
+
|
8
|
+
Using webpacker spelling is deprecated in Shakapacker.
|
9
|
+
Update your project with the new spelling.
|
10
|
+
|
11
|
+
For more information about this process, check:
|
12
|
+
#{DEPRECATION_GUIDE_URL}
|
13
|
+
MSG
|
14
|
+
SHELL = Thor::Shell::Color.new
|
15
|
+
|
16
|
+
def get_config_file_path_with_backward_compatibility(config_path)
|
17
|
+
if config_path.to_s.end_with?("shakapacker.yml") && !File.exist?(config_path)
|
18
|
+
webpacker_config_path = if config_path.class == Pathname
|
19
|
+
Pathname.new(config_path.to_s.gsub("shakapacker.yml", "webpacker.yml"))
|
20
|
+
else
|
21
|
+
config_path.gsub("shakapacker.yml", "webpacker.yml")
|
22
|
+
end
|
23
|
+
|
24
|
+
if File.exist?(webpacker_config_path)
|
25
|
+
puts_deprecation_message(
|
26
|
+
short_deprecation_message(
|
27
|
+
"config/webpacker.yml",
|
28
|
+
"config/shakapacker.yml"
|
29
|
+
)
|
30
|
+
)
|
31
|
+
return webpacker_config_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
config_path
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_shakapacker_env_variables_for_backward_compatibility
|
39
|
+
webpacker_env_variables = ENV.select { |key| key.start_with?("WEBPACKER_") }
|
40
|
+
|
41
|
+
deprecation_message_body = ""
|
42
|
+
|
43
|
+
webpacker_env_variables.each do |webpacker_key, _|
|
44
|
+
shakapacker_key = webpacker_key.gsub("WEBPACKER_", "SHAKAPACKER_")
|
45
|
+
next if ENV.key?(shakapacker_key)
|
46
|
+
|
47
|
+
deprecation_message_body += <<~MSG
|
48
|
+
Use `#{shakapacker_key}` instead of the deprecated `#{webpacker_key}`.
|
49
|
+
MSG
|
50
|
+
|
51
|
+
ENV[shakapacker_key] = ENV[webpacker_key]
|
52
|
+
end
|
53
|
+
|
54
|
+
if deprecation_message_body.present?
|
55
|
+
Shakapacker.puts_deprecation_message(
|
56
|
+
<<~MSG
|
57
|
+
DEPRECATION NOTICE:
|
58
|
+
|
59
|
+
#{deprecation_message_body}
|
60
|
+
Read more: #{Shakapacker::DEPRECATION_GUIDE_URL}
|
61
|
+
MSG
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def short_deprecation_message(old_usage, new_usage)
|
67
|
+
<<~MSG
|
68
|
+
DEPRECATION NOTICE:
|
69
|
+
|
70
|
+
Consider using `#{new_usage}` instead of the deprecated `#{old_usage}`.
|
71
|
+
Read more: #{DEPRECATION_GUIDE_URL}
|
72
|
+
MSG
|
73
|
+
end
|
74
|
+
|
75
|
+
def puts_deprecation_message(message)
|
76
|
+
SHELL.say "\n#{message}\n", :yellow
|
77
|
+
end
|
78
|
+
|
79
|
+
def puts_rake_deprecation_message(webpacker_task_name)
|
80
|
+
Shakapacker.puts_deprecation_message(
|
81
|
+
Shakapacker.short_deprecation_message(
|
82
|
+
"rake #{webpacker_task_name}",
|
83
|
+
"rake #{webpacker_task_name.gsub("webpacker", "shakapacker")}"
|
84
|
+
)
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class
|
2
|
-
DEFAULT_ENV_PREFIX = "
|
1
|
+
class Shakapacker::DevServer
|
2
|
+
DEFAULT_ENV_PREFIX = "SHAKAPACKER_DEV_SERVER".freeze
|
3
3
|
|
4
4
|
# Configure dev server connection timeout (in seconds), default: 0.1
|
5
|
-
#
|
5
|
+
# Shakapacker.dev_server.connect_timeout = 1
|
6
6
|
cattr_accessor(:connect_timeout) { 0.1 }
|
7
7
|
|
8
8
|
attr_reader :config
|
@@ -39,8 +39,29 @@ class Webpacker::DevServer
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def server
|
43
|
+
server_value = fetch(:server)
|
44
|
+
server_type = server_value.is_a?(Hash) ? server_value[:type] : server_value
|
45
|
+
|
46
|
+
return server_type if ["http", "https"].include?(server_type)
|
47
|
+
|
48
|
+
return "http" if server_type.nil?
|
49
|
+
|
50
|
+
puts <<~MSG
|
51
|
+
WARNING:
|
52
|
+
`server: #{server_type}` is not a valid configuration in Shakapacker.
|
53
|
+
Falling back to default `server: http`.
|
54
|
+
MSG
|
55
|
+
|
56
|
+
"http"
|
57
|
+
rescue KeyError
|
58
|
+
"http"
|
59
|
+
end
|
60
|
+
|
42
61
|
def protocol
|
43
|
-
https
|
62
|
+
return "https" if server == "https" || https? == true
|
63
|
+
|
64
|
+
"http"
|
44
65
|
end
|
45
66
|
|
46
67
|
def host_with_port
|
@@ -73,6 +94,8 @@ class Webpacker::DevServer
|
|
73
94
|
return nil unless config.dev_server.present?
|
74
95
|
|
75
96
|
ENV["#{env_prefix}_#{key.upcase}"] || config.dev_server.fetch(key, defaults[key])
|
97
|
+
rescue
|
98
|
+
nil
|
76
99
|
end
|
77
100
|
|
78
101
|
def defaults
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "rack/proxy"
|
2
2
|
|
3
|
-
class
|
4
|
-
delegate :config, :dev_server, to: :@
|
3
|
+
class Shakapacker::DevServerProxy < Rack::Proxy
|
4
|
+
delegate :config, :dev_server, to: :@instance
|
5
5
|
|
6
6
|
def initialize(app = nil, opts = {})
|
7
|
-
@
|
7
|
+
@instance = opts.delete(:shakapacker) || Shakapacker.instance
|
8
8
|
opts[:streaming] = false if Rails.env.test? && !opts.key?(:streaming)
|
9
9
|
super
|
10
10
|
end
|
@@ -15,7 +15,7 @@ class Webpacker::DevServerProxy < Rack::Proxy
|
|
15
15
|
env["HTTP_X_FORWARDED_SERVER"] = dev_server.host_with_port
|
16
16
|
env["HTTP_PORT"] = env["HTTP_X_FORWARDED_PORT"] = dev_server.port.to_s
|
17
17
|
env["HTTP_X_FORWARDED_PROTO"] = env["HTTP_X_FORWARDED_SCHEME"] = dev_server.protocol
|
18
|
-
unless dev_server.https
|
18
|
+
unless dev_server.protocol == "https"
|
19
19
|
env["HTTPS"] = env["HTTP_X_FORWARDED_SSL"] = "off"
|
20
20
|
end
|
21
21
|
env["SCRIPT_NAME"] = ""
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require "shellwords"
|
2
|
+
require "socket"
|
3
|
+
require "shakapacker/configuration"
|
4
|
+
require "shakapacker/dev_server"
|
5
|
+
require "shakapacker/runner"
|
6
|
+
|
7
|
+
module Shakapacker
|
8
|
+
class DevServerRunner < Shakapacker::Runner
|
9
|
+
def run
|
10
|
+
load_config
|
11
|
+
detect_unsupported_switches!
|
12
|
+
detect_port!
|
13
|
+
execute_cmd
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def load_config
|
19
|
+
app_root = Pathname.new(@app_path)
|
20
|
+
|
21
|
+
@config = Configuration.new(
|
22
|
+
root_path: app_root,
|
23
|
+
config_path: Pathname.new(@shakapacker_config),
|
24
|
+
env: ENV["RAILS_ENV"]
|
25
|
+
)
|
26
|
+
|
27
|
+
dev_server = DevServer.new(@config)
|
28
|
+
|
29
|
+
@hostname = dev_server.host
|
30
|
+
@port = dev_server.port
|
31
|
+
@pretty = dev_server.pretty?
|
32
|
+
@https = dev_server.protocol == "https"
|
33
|
+
@hot = dev_server.hmr?
|
34
|
+
|
35
|
+
rescue Errno::ENOENT, NoMethodError
|
36
|
+
$stdout.puts "webpack 'dev_server' configuration not found in #{@config.config_path}[#{ENV["RAILS_ENV"]}]."
|
37
|
+
$stdout.puts "Please run bundle exec rails shakapacker:install to install Shakapacker"
|
38
|
+
exit!
|
39
|
+
end
|
40
|
+
|
41
|
+
UNSUPPORTED_SWITCHES = %w[--host --port]
|
42
|
+
private_constant :UNSUPPORTED_SWITCHES
|
43
|
+
def detect_unsupported_switches!
|
44
|
+
unsupported_switches = UNSUPPORTED_SWITCHES & @argv
|
45
|
+
if unsupported_switches.any?
|
46
|
+
$stdout.puts "The following CLI switches are not supported by Shakapacker: #{unsupported_switches.join(' ')}. Please edit your command and try again."
|
47
|
+
exit!
|
48
|
+
end
|
49
|
+
|
50
|
+
if @argv.include?("--https") && !@https
|
51
|
+
$stdout.puts "Please set https: true in shakapacker.yml to use the --https command line flag."
|
52
|
+
exit!
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def detect_port!
|
57
|
+
server = TCPServer.new(@hostname, @port)
|
58
|
+
server.close
|
59
|
+
|
60
|
+
rescue Errno::EADDRINUSE
|
61
|
+
$stdout.puts "Another program is running on port #{@port}. Set a new port in #{@config.config_path} for dev_server"
|
62
|
+
exit!
|
63
|
+
end
|
64
|
+
|
65
|
+
def execute_cmd
|
66
|
+
env = Shakapacker::Compiler.env
|
67
|
+
env["SHAKAPACKER_CONFIG"] = @shakapacker_config
|
68
|
+
env["WEBPACK_SERVE"] = "true"
|
69
|
+
|
70
|
+
cmd = if node_modules_bin_exist?
|
71
|
+
["#{@node_modules_bin_path}/webpack", "serve"]
|
72
|
+
else
|
73
|
+
["yarn", "webpack", "serve"]
|
74
|
+
end
|
75
|
+
|
76
|
+
if @argv.include?("--debug-webpacker")
|
77
|
+
Shakapacker.puts_deprecation_message(
|
78
|
+
Shakapacker.short_deprecation_message(
|
79
|
+
"--debug-webpacker",
|
80
|
+
"--debug-shakapacker"
|
81
|
+
)
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
if @argv.delete("--debug-shakapacker") || @argv.delete("--debug-webpacker")
|
86
|
+
cmd = [ "node", "--inspect-brk", "--trace-warnings" ] + cmd
|
87
|
+
end
|
88
|
+
|
89
|
+
cmd += ["--config", @webpack_config]
|
90
|
+
cmd += ["--progress", "--color"] if @pretty
|
91
|
+
|
92
|
+
cmd += ["--hot"] if @hot
|
93
|
+
cmd += @argv
|
94
|
+
|
95
|
+
Dir.chdir(@app_path) do
|
96
|
+
Kernel.exec env, *cmd
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def node_modules_bin_exist?
|
101
|
+
File.exist?("#{@node_modules_bin_path}/webpack-dev-server")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "digest/sha1"
|
2
|
-
require "
|
2
|
+
require "shakapacker/base_strategy"
|
3
3
|
|
4
|
-
module
|
4
|
+
module Shakapacker
|
5
5
|
class DigestStrategy < BaseStrategy
|
6
6
|
# Returns true if all the compiled packs are up to date with the underlying asset files.
|
7
7
|
def fresh?
|
@@ -31,10 +31,10 @@ module Webpacker
|
|
31
31
|
def watched_files_digest
|
32
32
|
if Rails.env.development?
|
33
33
|
warn <<~MSG.strip
|
34
|
-
|
34
|
+
Shakapacker::Compiler - Slow setup for development
|
35
35
|
Prepare JS assets with either:
|
36
|
-
1. Running `bin/
|
37
|
-
2. Set `compile` to false in
|
36
|
+
1. Running `bin/shakapacker-dev-server`
|
37
|
+
2. Set `compile` to false in shakapacker.yml and run `bin/shakapacker -w`
|
38
38
|
MSG
|
39
39
|
end
|
40
40
|
|
@@ -53,7 +53,7 @@ module Webpacker
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def compilation_digest_path
|
56
|
-
config.cache_path.join("last-compilation-digest-#{
|
56
|
+
config.cache_path.join("last-compilation-digest-#{Shakapacker.env}")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
class
|
2
|
-
delegate :config_path, :logger, to: :@
|
1
|
+
class Shakapacker::Env
|
2
|
+
delegate :config_path, :logger, to: :@instance
|
3
3
|
|
4
|
-
def self.inquire(
|
5
|
-
new(
|
4
|
+
def self.inquire(instance)
|
5
|
+
new(instance).inquire
|
6
6
|
end
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(instance)
|
9
|
+
@instance = instance
|
10
10
|
end
|
11
11
|
|
12
12
|
def inquire
|
13
13
|
fallback_env_warning if config_path.exist? && !current
|
14
|
-
current ||
|
14
|
+
current || Shakapacker::DEFAULT_ENV.inquiry
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -20,7 +20,7 @@ class Webpacker::Env
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def fallback_env_warning
|
23
|
-
logger.info "RAILS_ENV=#{Rails.env} environment is not defined in config/
|
23
|
+
logger.info "RAILS_ENV=#{Rails.env} environment is not defined in config/shakapacker.yml, falling back to #{Shakapacker::DEFAULT_ENV} environment"
|
24
24
|
end
|
25
25
|
|
26
26
|
def available_environments
|