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
data/package/index.js
CHANGED
@@ -10,19 +10,42 @@ const config = require('./config')
|
|
10
10
|
const devServer = require('./dev_server')
|
11
11
|
const env = require('./env')
|
12
12
|
const { moduleExists, canProcess } = require('./utils/helpers')
|
13
|
-
const inliningCss = require('./inliningCss')
|
13
|
+
const inliningCss = require('./utils/inliningCss')
|
14
14
|
|
15
|
-
const
|
15
|
+
const globalMutableWebpackConfig = () => {
|
16
16
|
const { nodeEnv } = env
|
17
17
|
const path = resolve(__dirname, 'environments', `${nodeEnv}.js`)
|
18
18
|
const environmentConfig = existsSync(path) ? require(path) : baseConfig
|
19
19
|
return environmentConfig
|
20
20
|
}
|
21
21
|
|
22
|
+
const generateWebpackConfig = () => {
|
23
|
+
const environmentConfig = globalMutableWebpackConfig()
|
24
|
+
const immutable = webpackMerge.merge({}, environmentConfig)
|
25
|
+
return immutable
|
26
|
+
}
|
27
|
+
|
28
|
+
const webpackConfigForBackwardCompatibility = () => {
|
29
|
+
// eslint-disable-next-line no-console
|
30
|
+
console.log(`⚠️
|
31
|
+
DEPRECATION NOTICE:
|
32
|
+
The 'webpackConfig' is deprecated and will be removed in a future version.
|
33
|
+
Please use 'globalMutableWebpackConfig' instead, or use
|
34
|
+
'generateWebpackConfig()' to avoid unwanted config manipulation across the app.
|
35
|
+
|
36
|
+
For more information, see version 7 upgrade documentation at:
|
37
|
+
https://github.com/shakacode/shakapacker/blob/master/docs/v7_upgrade.md
|
38
|
+
`)
|
39
|
+
|
40
|
+
return globalMutableWebpackConfig()
|
41
|
+
}
|
42
|
+
|
22
43
|
module.exports = {
|
23
|
-
config,
|
44
|
+
config, // shakapacker.yml
|
24
45
|
devServer,
|
25
|
-
|
46
|
+
generateWebpackConfig,
|
47
|
+
globalMutableWebpackConfig: globalMutableWebpackConfig(),
|
48
|
+
webpackConfig: webpackConfigForBackwardCompatibility(),
|
26
49
|
baseConfig,
|
27
50
|
env,
|
28
51
|
rules,
|
@@ -16,7 +16,7 @@ const createTrackLoader = () => {
|
|
16
16
|
|
17
17
|
const node_modules = path.resolve("node_modules");
|
18
18
|
const node_modules_included = path.resolve("node_modules/included");
|
19
|
-
const app_javascript = path.resolve("app/
|
19
|
+
const app_javascript = path.resolve("app/javascript");
|
20
20
|
|
21
21
|
const createInMemoryFs = () => {
|
22
22
|
const fs = new MemoryFS();
|
@@ -32,4 +32,31 @@ describe('file', () => {
|
|
32
32
|
]
|
33
33
|
types.forEach(type => expect(file.exclude.test(type)).toBe(true))
|
34
34
|
})
|
35
|
+
|
36
|
+
test('correct generated output path is returned for top level files', () => {
|
37
|
+
const pathData = {
|
38
|
+
filename: 'app/javascript/image.svg',
|
39
|
+
};
|
40
|
+
expect(file.generator.filename(pathData)).toEqual(
|
41
|
+
'static/[name]-[hash][ext][query]'
|
42
|
+
);
|
43
|
+
});
|
44
|
+
|
45
|
+
test('correct generated output path is returned for nested files', () => {
|
46
|
+
const pathData = {
|
47
|
+
filename: 'app/javascript/images/image.svg',
|
48
|
+
};
|
49
|
+
expect(file.generator.filename(pathData)).toEqual(
|
50
|
+
'static/images/[name]-[hash][ext][query]'
|
51
|
+
);
|
52
|
+
})
|
53
|
+
|
54
|
+
test('correct generated output path is returned for deeply nested files', () => {
|
55
|
+
const pathData = {
|
56
|
+
filename: 'app/javascript/images/nested/deeply/image.svg',
|
57
|
+
};
|
58
|
+
expect(file.generator.filename(pathData)).toEqual(
|
59
|
+
'static/images/nested/deeply/[name]-[hash][ext][query]'
|
60
|
+
);
|
61
|
+
});
|
35
62
|
})
|
@@ -1,4 +1,3 @@
|
|
1
|
-
const path = require("path");
|
2
1
|
const {
|
3
2
|
app_javascript,
|
4
3
|
node_modules,
|
@@ -36,7 +35,7 @@ const createWebpackConfig = (file, use) => {
|
|
36
35
|
};
|
37
36
|
|
38
37
|
describe("swc", () => {
|
39
|
-
test("process
|
38
|
+
test("process files in source_path", async () => {
|
40
39
|
const normalPath = `${app_javascript}/a.js`;
|
41
40
|
const [tracked, loader] = createTrackLoader();
|
42
41
|
const compiler = createTestCompiler(
|
data/package/rules/file.js
CHANGED
@@ -8,9 +8,9 @@ module.exports = {
|
|
8
8
|
generator: {
|
9
9
|
filename: (pathData) => {
|
10
10
|
const folders = dirname(pathData.filename)
|
11
|
-
.replace(`${sourcePath}
|
11
|
+
.replace(`${sourcePath}`, '')
|
12
12
|
.split('/')
|
13
|
-
.
|
13
|
+
.filter(Boolean)
|
14
14
|
|
15
15
|
const foldersWithStatic = ['static', ...folders].join('/')
|
16
16
|
return `${foldersWithStatic}/[name]-[hash][ext][query]`
|
@@ -0,0 +1,19 @@
|
|
1
|
+
const fs = require('fs')
|
2
|
+
const { resolve } = require('path')
|
3
|
+
const { setShakapackerEnvVariablesForBackwardCompatibility } = require('./helpers')
|
4
|
+
|
5
|
+
setShakapackerEnvVariablesForBackwardCompatibility()
|
6
|
+
|
7
|
+
// For backward compatibility
|
8
|
+
const resolveToPhysicalFilePath = () => {
|
9
|
+
const shakapackerConfigPath = resolve('config', 'shakapacker.yml')
|
10
|
+
const webpackerConfigPath = resolve('config', 'webpacker.yml')
|
11
|
+
|
12
|
+
if (fs.existsSync(shakapackerConfigPath)) return shakapackerConfigPath
|
13
|
+
if (fs.existsSync(webpackerConfigPath)) return webpackerConfigPath
|
14
|
+
|
15
|
+
// If neither of files exist, try to resolve to shakapacker.yml to get more relevant error
|
16
|
+
return shakapackerConfigPath
|
17
|
+
}
|
18
|
+
|
19
|
+
module.exports = process.env.SHAKAPACKER_CONFIG || resolveToPhysicalFilePath()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
2
|
const { canProcess, moduleExists } = require('./helpers')
|
3
|
-
const inliningCss = require('
|
3
|
+
const inliningCss = require('./inliningCss')
|
4
4
|
|
5
5
|
const getStyleRule = (test, preprocessors = []) => {
|
6
6
|
if (moduleExists('css-loader')) {
|
@@ -18,7 +18,10 @@ const getStyleRule = (test, preprocessors = []) => {
|
|
18
18
|
loader: require.resolve('css-loader'),
|
19
19
|
options: {
|
20
20
|
sourceMap: true,
|
21
|
-
importLoaders: 2
|
21
|
+
importLoaders: 2,
|
22
|
+
modules: {
|
23
|
+
auto: true
|
24
|
+
}
|
22
25
|
}
|
23
26
|
},
|
24
27
|
tryPostcss(),
|
data/package/utils/helpers.js
CHANGED
@@ -2,7 +2,16 @@ const isArray = (value) => Array.isArray(value)
|
|
2
2
|
const isBoolean = (str) => /^true/.test(str) || /^false/.test(str)
|
3
3
|
const chdirTestApp = () => {
|
4
4
|
try {
|
5
|
-
return process.chdir('spec/test_app')
|
5
|
+
return process.chdir('spec/shakapacker/test_app')
|
6
|
+
} catch (e) {
|
7
|
+
return null
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
// For backward compatibility
|
12
|
+
const chdirWebpackerTestApp = () => {
|
13
|
+
try {
|
14
|
+
return process.chdir('spec/backward_compatibility_specs/webpacker_test_app')
|
6
15
|
} catch (e) {
|
7
16
|
return null
|
8
17
|
}
|
@@ -48,15 +57,29 @@ const loaderMatches = (configLoader, loaderToCheck, fn) => {
|
|
48
57
|
|
49
58
|
if (!moduleExists(loaderName)) {
|
50
59
|
throw new Error(
|
51
|
-
`Your
|
60
|
+
`Your Shakapacker config specified using ${configLoader}, but ${loaderName} package is not installed. Please install ${loaderName} first.`
|
52
61
|
)
|
53
62
|
}
|
54
63
|
|
55
64
|
return fn()
|
56
65
|
}
|
57
66
|
|
67
|
+
// For backward compatibility
|
68
|
+
// Set SHAKAPACKER_XYZ only if SHAKAPACKER_XYZ is not defined but WEBPACKER_XYZ is.
|
69
|
+
const setShakapackerEnvVariablesForBackwardCompatibility = () => {
|
70
|
+
const webpackerEnvVariables = Object.entries(process.env).filter((key) => /^WEBPACKER_/.test(key))
|
71
|
+
webpackerEnvVariables.forEach(([webpackerEnvKey, webpackerEnvValue]) => {
|
72
|
+
const shakapackerKey = webpackerEnvKey.replace(/^WEBPACKER/, 'SHAKAPACKER')
|
73
|
+
if (!process.env[shakapackerKey]) {
|
74
|
+
process.env[shakapackerKey] = webpackerEnvValue
|
75
|
+
}
|
76
|
+
})
|
77
|
+
}
|
78
|
+
|
58
79
|
module.exports = {
|
59
80
|
chdirTestApp,
|
81
|
+
chdirWebpackerTestApp,
|
82
|
+
setShakapackerEnvVariablesForBackwardCompatibility,
|
60
83
|
chdirCwd,
|
61
84
|
isArray,
|
62
85
|
isBoolean,
|
@@ -0,0 +1,7 @@
|
|
1
|
+
const { runningWebpackDevServer } = require('../env')
|
2
|
+
const devServer = require('../dev_server')
|
3
|
+
|
4
|
+
// This logic is tied to lib/shakapacker/instance.rb
|
5
|
+
const inliningCss = runningWebpackDevServer && devServer.hmr && devServer.inline_css !== false
|
6
|
+
|
7
|
+
module.exports = inliningCss
|
@@ -0,0 +1,68 @@
|
|
1
|
+
const shakapackerDevServerYamlConfig = require('./dev_server')
|
2
|
+
const snakeToCamelCase = require('./utils/snakeToCamelCase')
|
3
|
+
const { outputPath: contentBase, publicPath } = require('./config')
|
4
|
+
|
5
|
+
const webpackDevServerMappedKeys = new Set([
|
6
|
+
// client, server, liveReload, devMiddleware are handled separately
|
7
|
+
'allowedHosts',
|
8
|
+
'bonjour',
|
9
|
+
'compress',
|
10
|
+
'headers',
|
11
|
+
'historyApiFallback',
|
12
|
+
'host',
|
13
|
+
'hot',
|
14
|
+
'http2',
|
15
|
+
'https',
|
16
|
+
'ipc',
|
17
|
+
'magicHtml',
|
18
|
+
'onAfterSetupMiddleware',
|
19
|
+
'onBeforeSetupMiddleware',
|
20
|
+
'open',
|
21
|
+
'port',
|
22
|
+
'proxy',
|
23
|
+
'server',
|
24
|
+
'setupExitSignals',
|
25
|
+
'setupMiddlewares',
|
26
|
+
'watchFiles',
|
27
|
+
'webSocketServer'
|
28
|
+
])
|
29
|
+
|
30
|
+
function createDevServerConfig() {
|
31
|
+
const devServerYamlConfig = { ...shakapackerDevServerYamlConfig }
|
32
|
+
const liveReload = devServerYamlConfig.live_reload !== undefined ? devServerYamlConfig.live_reload : !devServerYamlConfig.hmr
|
33
|
+
delete devServerYamlConfig.live_reload
|
34
|
+
|
35
|
+
const config = {
|
36
|
+
devMiddleware: {
|
37
|
+
publicPath
|
38
|
+
},
|
39
|
+
liveReload,
|
40
|
+
historyApiFallback: {
|
41
|
+
disableDotRule: true
|
42
|
+
},
|
43
|
+
static: {
|
44
|
+
publicPath: contentBase
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
if (devServerYamlConfig.static) {
|
49
|
+
config.static = { ...config.static, ...devServerYamlConfig.static }
|
50
|
+
delete devServerYamlConfig.static
|
51
|
+
}
|
52
|
+
|
53
|
+
if (devServerYamlConfig.client) {
|
54
|
+
config.client = devServerYamlConfig.client
|
55
|
+
delete devServerYamlConfig.client
|
56
|
+
}
|
57
|
+
|
58
|
+
Object.keys(devServerYamlConfig).forEach((yamlKey) => {
|
59
|
+
const camelYamlKey = snakeToCamelCase(yamlKey)
|
60
|
+
if (webpackDevServerMappedKeys.has(camelYamlKey)) {
|
61
|
+
config[camelYamlKey] = devServerYamlConfig[yamlKey]
|
62
|
+
}
|
63
|
+
})
|
64
|
+
|
65
|
+
return config
|
66
|
+
}
|
67
|
+
|
68
|
+
module.exports = createDevServerConfig
|
data/package.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "shakapacker",
|
3
|
-
"version": "
|
3
|
+
"version": "7.0.0-rc.1",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"main": "package/index.js",
|
6
6
|
"files": [
|
7
7
|
"package",
|
8
|
-
"lib/install/config/
|
8
|
+
"lib/install/config/shakapacker.yml"
|
9
9
|
],
|
10
10
|
"engines": {
|
11
11
|
"node": "^12.13.0 || ^14 || >=16",
|
@@ -1,16 +1,16 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
|
-
require "
|
2
|
+
require "shakapacker/version"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "shakapacker"
|
6
|
-
s.version =
|
6
|
+
s.version = Shakapacker::VERSION
|
7
7
|
s.authors = [ "David Heinemeier Hansson", "Gaurav Tiwari", "Justin Gordon" ]
|
8
8
|
s.email = [ "david@basecamp.com", "gaurav@gauravtiwari.co.uk", "justin@shakacode.com" ]
|
9
9
|
s.summary = "Use webpack to manage app-like JavaScript modules in Rails"
|
10
10
|
s.homepage = "https://github.com/shakacode/shakapacker"
|
11
11
|
s.license = "MIT"
|
12
12
|
|
13
|
-
npm_version =
|
13
|
+
npm_version = Shakapacker::VERSION.gsub(".rc", "-rc")
|
14
14
|
s.metadata = {
|
15
15
|
"source_code_uri" => "https://github.com/shakacode/shakapacker/tree/v#{npm_version}",
|
16
16
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "spec_helper_initializer"
|
2
|
+
|
1
3
|
describe "Webpacker::Compiler" do
|
2
4
|
it "accepts custom environment variables" do
|
3
5
|
expect(Webpacker.compiler.send(:webpack_env)["FOO"]).to be nil
|
@@ -45,13 +47,13 @@ describe "Webpacker::Compiler" do
|
|
45
47
|
end
|
46
48
|
|
47
49
|
it "accepts external env variables" do
|
48
|
-
expect(Webpacker.compiler.send(:webpack_env)["
|
49
|
-
expect(Webpacker.compiler.send(:webpack_env)["
|
50
|
+
expect(Webpacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to be nil
|
51
|
+
expect(Webpacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to be nil
|
50
52
|
|
51
53
|
ENV["WEBPACKER_ASSET_HOST"] = "foo.bar"
|
52
54
|
ENV["WEBPACKER_RELATIVE_URL_ROOT"] = "/baz"
|
53
55
|
|
54
|
-
expect(Webpacker.compiler.send(:webpack_env)["
|
55
|
-
expect(Webpacker.compiler.send(:webpack_env)["
|
56
|
+
expect(Webpacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to eq "foo.bar"
|
57
|
+
expect(Webpacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to eq "/baz"
|
56
58
|
end
|
57
59
|
end
|
@@ -1,47 +1,49 @@
|
|
1
|
+
require_relative "spec_helper_initializer"
|
2
|
+
|
1
3
|
describe "Webpacker::Configuration" do
|
2
|
-
ROOT_PATH = Pathname.new(File.expand_path("
|
4
|
+
ROOT_PATH = Pathname.new(File.expand_path("webpacker_test_app", __dir__))
|
3
5
|
|
4
6
|
context "with standard webpacker.yml" do
|
5
7
|
let(:config) do
|
6
8
|
Webpacker::Configuration.new(
|
7
9
|
root_path: ROOT_PATH,
|
8
|
-
config_path: Pathname.new(File.expand_path("./
|
10
|
+
config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/webpacker.yml", __dir__)),
|
9
11
|
env: "production"
|
10
12
|
)
|
11
13
|
end
|
12
14
|
|
13
15
|
it "#source_path returns correct path" do
|
14
|
-
source_path = File.expand_path File.join(File.dirname(__FILE__), "
|
16
|
+
source_path = File.expand_path File.join(File.dirname(__FILE__), "webpacker_test_app/app/packs").to_s
|
15
17
|
expect(config.source_path.to_s).to eq source_path
|
16
18
|
end
|
17
19
|
|
18
20
|
it "#source_entry_path returns correct path" do
|
19
|
-
source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "
|
21
|
+
source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "webpacker_test_app/app/packs", "entrypoints").to_s
|
20
22
|
expect(config.source_entry_path.to_s).to eq source_entry_path
|
21
23
|
end
|
22
24
|
|
23
25
|
it "#public_root_path returns correct path" do
|
24
|
-
public_root_path = File.expand_path File.join(File.dirname(__FILE__), "
|
26
|
+
public_root_path = File.expand_path File.join(File.dirname(__FILE__), "webpacker_test_app/public").to_s
|
25
27
|
expect(config.public_path.to_s).to eq public_root_path
|
26
28
|
end
|
27
29
|
|
28
30
|
it "#public_output_path returns correct path" do
|
29
|
-
public_output_path = File.expand_path File.join(File.dirname(__FILE__), "
|
31
|
+
public_output_path = File.expand_path File.join(File.dirname(__FILE__), "webpacker_test_app/public/packs").to_s
|
30
32
|
expect(config.public_output_path.to_s).to eq public_output_path
|
31
33
|
end
|
32
34
|
|
33
35
|
it "#public_manifest_path returns correct path" do
|
34
|
-
public_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "
|
36
|
+
public_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "webpacker_test_app/public/packs", "manifest.json").to_s
|
35
37
|
expect(config.public_manifest_path.to_s).to eq public_manifest_path
|
36
38
|
end
|
37
39
|
|
38
40
|
it "#manifest_path returns correct path" do
|
39
|
-
manifest_path = File.expand_path File.join(File.dirname(__FILE__), "
|
41
|
+
manifest_path = File.expand_path File.join(File.dirname(__FILE__), "webpacker_test_app/public/packs", "manifest.json").to_s
|
40
42
|
expect(config.manifest_path.to_s).to eq manifest_path
|
41
43
|
end
|
42
44
|
|
43
45
|
it "#cache_path returns correct path" do
|
44
|
-
cache_path = File.expand_path File.join(File.dirname(__FILE__), "
|
46
|
+
cache_path = File.expand_path File.join(File.dirname(__FILE__), "webpacker_test_app/tmp/webpacker").to_s
|
45
47
|
expect(config.cache_path.to_s).to eq cache_path
|
46
48
|
end
|
47
49
|
|
@@ -123,7 +125,8 @@ describe "Webpacker::Configuration" do
|
|
123
125
|
|
124
126
|
describe "#webpacker_precompile?" do
|
125
127
|
before :each do
|
126
|
-
ENV
|
128
|
+
ENV.delete("SHAKAPACKER_PRECOMPILE")
|
129
|
+
ENV.delete("WEBPACKER_PRECOMPILE")
|
127
130
|
end
|
128
131
|
|
129
132
|
subject { config.webpacker_precompile? }
|
@@ -177,7 +180,7 @@ describe "Webpacker::Configuration" do
|
|
177
180
|
context "with webpacker config file containing public_output_path entry" do
|
178
181
|
config = Webpacker::Configuration.new(
|
179
182
|
root_path: ROOT_PATH,
|
180
|
-
config_path: Pathname.new(File.expand_path("./
|
183
|
+
config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/webpacker_public_root.yml", __dir__)),
|
181
184
|
env: "production"
|
182
185
|
)
|
183
186
|
|
@@ -190,12 +193,12 @@ describe "Webpacker::Configuration" do
|
|
190
193
|
context "with webpacker config file containing manifext_path entry" do
|
191
194
|
config = Webpacker::Configuration.new(
|
192
195
|
root_path: ROOT_PATH,
|
193
|
-
config_path: Pathname.new(File.expand_path("./
|
196
|
+
config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/webpacker_manifest_path.yml", __dir__)),
|
194
197
|
env: "production"
|
195
198
|
)
|
196
199
|
|
197
200
|
it "#manifest_path returns correct expected value" do
|
198
|
-
expected_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "
|
201
|
+
expected_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "webpacker_test_app/app/packs", "manifest.json").to_s
|
199
202
|
expect(config.manifest_path.to_s).to eq expected_manifest_path
|
200
203
|
end
|
201
204
|
end
|
@@ -203,13 +206,14 @@ describe "Webpacker::Configuration" do
|
|
203
206
|
context "with webpacker_precompile entry set to false" do
|
204
207
|
describe "#webpacker_precompile?" do
|
205
208
|
before :each do
|
206
|
-
ENV
|
209
|
+
ENV.delete("WEBPACKER_PRECOMPILE")
|
210
|
+
ENV.delete("SHAKAPACKER_PRECOMPILE")
|
207
211
|
end
|
208
212
|
|
209
213
|
let(:config) {
|
210
214
|
Webpacker::Configuration.new(
|
211
215
|
root_path: ROOT_PATH,
|
212
|
-
config_path: Pathname.new(File.expand_path("./
|
216
|
+
config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/webpacker_no_precompile.yml", __dir__)),
|
213
217
|
env: "production"
|
214
218
|
)
|
215
219
|
}
|
@@ -225,8 +229,9 @@ describe "Webpacker::Configuration" do
|
|
225
229
|
expect(subject).to be true
|
226
230
|
end
|
227
231
|
|
228
|
-
it "returns false with WEBPACKER_PRECOMPILE set to
|
229
|
-
ENV["WEBPACKER_PRECOMPILE"] =
|
232
|
+
it "returns false with WEBPACKER_PRECOMPILE set to falsy value" do
|
233
|
+
# ENV["WEBPACKER_PRECOMPILE"] = "no"
|
234
|
+
ENV.delete("WEBPACKER_PRECOMPILE")
|
230
235
|
expect(subject).to be false
|
231
236
|
end
|
232
237
|
end
|
@@ -235,7 +240,7 @@ describe "Webpacker::Configuration" do
|
|
235
240
|
context "with webpacker config file containing invalid path" do
|
236
241
|
config = Webpacker::Configuration.new(
|
237
242
|
root_path: ROOT_PATH,
|
238
|
-
config_path: Pathname.new(File.expand_path("./
|
243
|
+
config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/invalid_path.yml", __dir__)),
|
239
244
|
env: "default"
|
240
245
|
)
|
241
246
|
|
@@ -248,7 +253,7 @@ describe "Webpacker::Configuration" do
|
|
248
253
|
let(:config) do
|
249
254
|
Webpacker::Configuration.new(
|
250
255
|
root_path: ROOT_PATH,
|
251
|
-
config_path: Pathname.new(File.expand_path("./
|
256
|
+
config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/webpacker_defaults_fallback.yml", __dir__)),
|
252
257
|
env: "default"
|
253
258
|
)
|
254
259
|
end
|
@@ -266,7 +271,7 @@ describe "Webpacker::Configuration" do
|
|
266
271
|
let(:config) do
|
267
272
|
Webpacker::Configuration.new(
|
268
273
|
root_path: ROOT_PATH,
|
269
|
-
config_path: Pathname.new(File.expand_path("./
|
274
|
+
config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/webpacker_defaults_fallback.yml", __dir__)),
|
270
275
|
env: "staging"
|
271
276
|
)
|
272
277
|
end
|
data/spec/{dev_server_runner_spec.rb → backward_compatibility_specs/dev_server_runner_spec.rb}
RENAMED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "spec_helper_initializer"
|
2
|
+
# Requiring from webpacker directory to ensure old ./bin/webpacker-dev-server works fine
|
1
3
|
require "webpacker/dev_server_runner"
|
2
4
|
|
3
5
|
describe "DevServerRunner" do
|
@@ -13,20 +15,23 @@ describe "DevServerRunner" do
|
|
13
15
|
ENV["WEBPACKER_CONFIG"] = @original_webpacker_config
|
14
16
|
end
|
15
17
|
|
16
|
-
let(:test_app_path) { File.expand_path("
|
18
|
+
let(:test_app_path) { File.expand_path("webpacker_test_app", __dir__) }
|
17
19
|
|
18
20
|
it "run cmd via node modules" do
|
19
21
|
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
20
22
|
verify_command(cmd, use_node_modules: true)
|
21
23
|
end
|
24
|
+
|
22
25
|
it "run cmd via yarn" do
|
23
26
|
cmd = ["yarn", "webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
24
27
|
verify_command(cmd, use_node_modules: false)
|
25
28
|
end
|
29
|
+
|
26
30
|
it "run cmd argv" do
|
27
31
|
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--quiet"]
|
28
32
|
verify_command(cmd, argv: (["--quiet"]))
|
29
33
|
end
|
34
|
+
|
30
35
|
it "run cmd argv with https" do
|
31
36
|
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--https"]
|
32
37
|
|
@@ -41,10 +46,13 @@ describe "DevServerRunner" do
|
|
41
46
|
verify_command(cmd, argv: (["--https"]))
|
42
47
|
end.and_return(dev_server)
|
43
48
|
end
|
49
|
+
|
44
50
|
it "accepts environment variables" do
|
45
51
|
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
46
52
|
env = Webpacker::Compiler.env.dup
|
47
|
-
|
53
|
+
|
54
|
+
# ENV["WEBPACKER_CONFIG"] is the interface and env["SHAKAPACKER_CONFIG"] is internal
|
55
|
+
ENV["WEBPACKER_CONFIG"] = env["SHAKAPACKER_CONFIG"] = "#{test_app_path}/config/webpacker_other_location.yml"
|
48
56
|
env["WEBPACK_SERVE"] = "true"
|
49
57
|
verify_command(cmd, env: env)
|
50
58
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "spec_helper_initializer"
|
2
|
+
|
1
3
|
describe "DevServer" do
|
2
4
|
it "doesn't run by default" do
|
3
5
|
expect(Webpacker.dev_server.running?).to be_falsy
|
@@ -39,7 +41,7 @@ describe "DevServer" do
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
|
-
it "users
|
43
|
-
expect(Webpacker::DevServer::DEFAULT_ENV_PREFIX).to eq "
|
44
|
+
it "users SHAKAPACKER_DEV_SERVER for DEFAULT_ENV_PREFIX" do
|
45
|
+
expect(Webpacker::DevServer::DEFAULT_ENV_PREFIX).to eq "SHAKAPACKER_DEV_SERVER"
|
44
46
|
end
|
45
47
|
end
|
data/spec/{engine_rake_tasks_spec.rb → backward_compatibility_specs/engine_rake_tasks_spec.rb}
RENAMED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "spec_helper_initializer"
|
2
|
+
|
1
3
|
describe "EngineRakeTasks" do
|
2
4
|
before :context do
|
3
5
|
remove_webpack_binstubs
|
@@ -9,38 +11,33 @@ describe "EngineRakeTasks" do
|
|
9
11
|
|
10
12
|
it "mounts app:webpacker task successfully" do
|
11
13
|
output = Dir.chdir(mounted_app_path) { `rake -T` }
|
12
|
-
expect(output).to
|
14
|
+
expect(output).to match /app:webpacker.+DEPRECATED/
|
15
|
+
expect(output).to match /app:webpacker:binstubs.+DEPRECATED/
|
13
16
|
end
|
14
17
|
|
15
18
|
it "binstubs adds only expected files to bin directory" do
|
16
|
-
original_files_in_bin = current_files_in_bin
|
17
|
-
|
18
19
|
Dir.chdir(mounted_app_path) { `bundle exec rake app:webpacker:binstubs` }
|
19
|
-
|
20
|
-
|
21
|
-
# and no other files are added
|
22
|
-
expect(current_files_in_bin - webpack_binstub_paths).to match_array original_files_in_bin
|
20
|
+
expected_binstub_paths.each { |path| expect(File.exist?(path)).to be true }
|
23
21
|
end
|
24
22
|
|
25
23
|
private
|
26
24
|
def mounted_app_path
|
27
|
-
File.expand_path("mounted_app", __dir__)
|
25
|
+
File.expand_path("../mounted_app", __dir__)
|
28
26
|
end
|
29
27
|
|
30
28
|
def current_files_in_bin
|
31
29
|
Dir.glob("#{mounted_app_path}/test/dummy/bin/*")
|
32
30
|
end
|
33
31
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
"#{mounted_app_path}/test/dummy/bin
|
38
|
-
|
39
|
-
]
|
32
|
+
def expected_binstub_paths
|
33
|
+
gem_path = File.expand_path("../..", __dir__)
|
34
|
+
Dir.chdir("#{gem_path}/lib/install/bin") do
|
35
|
+
Dir.glob("*").map { |file| "#{mounted_app_path}/test/dummy/bin/#{file}" }
|
36
|
+
end
|
40
37
|
end
|
41
38
|
|
42
39
|
def remove_webpack_binstubs
|
43
|
-
|
40
|
+
expected_binstub_paths.each do |path|
|
44
41
|
File.delete(path) if File.exist?(path)
|
45
42
|
end
|
46
43
|
end
|