webpacker 5.4.4 → 6.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +1 -1
  3. data/.github/workflows/ruby.yml +28 -4
  4. data/.gitignore +2 -0
  5. data/.node-version +1 -1
  6. data/.rubocop.yml +3 -111
  7. data/6_0_upgrade.md +43 -0
  8. data/CHANGELOG.md +19 -26
  9. data/Gemfile.lock +91 -94
  10. data/README.md +215 -98
  11. data/gemfiles/Gemfile-rails-edge +1 -1
  12. data/lib/install/config/webpack/base.js +3 -0
  13. data/lib/install/config/webpack/development.js +2 -2
  14. data/lib/install/config/webpack/production.js +2 -2
  15. data/lib/install/config/webpack/test.js +2 -2
  16. data/lib/install/config/webpacker.yml +8 -37
  17. data/lib/install/javascript/packs/application.css +9 -0
  18. data/lib/install/javascript/packs/application.js +3 -1
  19. data/lib/install/template.rb +33 -27
  20. data/lib/tasks/webpacker/binstubs.rake +6 -4
  21. data/lib/tasks/webpacker/check_binstubs.rake +4 -4
  22. data/lib/tasks/webpacker/check_yarn.rake +1 -1
  23. data/lib/tasks/webpacker/compile.rake +4 -2
  24. data/lib/tasks/webpacker/info.rake +12 -10
  25. data/lib/tasks/webpacker/install.rake +6 -4
  26. data/lib/tasks/webpacker/verify_install.rake +2 -1
  27. data/lib/tasks/webpacker/yarn_install.rake +9 -7
  28. data/lib/tasks/webpacker.rake +2 -11
  29. data/lib/webpacker/compiler.rb +15 -8
  30. data/lib/webpacker/configuration.rb +10 -45
  31. data/lib/webpacker/dev_server_runner.rb +21 -2
  32. data/lib/webpacker/env.rb +1 -5
  33. data/lib/webpacker/helper.rb +22 -32
  34. data/lib/webpacker/manifest.rb +1 -1
  35. data/lib/webpacker/version.rb +1 -1
  36. data/lib/webpacker/webpack_runner.rb +5 -0
  37. data/package/__tests__/config.js +5 -37
  38. data/package/__tests__/development.js +9 -11
  39. data/package/__tests__/env.js +12 -4
  40. data/package/__tests__/production.js +6 -6
  41. data/package/__tests__/staging.js +7 -6
  42. data/package/__tests__/test.js +4 -5
  43. data/package/babel/preset.js +55 -0
  44. data/package/config.js +3 -11
  45. data/package/env.js +8 -2
  46. data/package/environments/__tests__/base.js +15 -47
  47. data/package/environments/base.js +62 -125
  48. data/package/environments/development.js +45 -44
  49. data/package/environments/production.js +63 -68
  50. data/package/environments/test.js +2 -2
  51. data/package/index.js +13 -8
  52. data/package/rules/babel.js +9 -7
  53. data/package/rules/coffee.js +6 -0
  54. data/package/rules/erb.js +15 -0
  55. data/package/rules/file.js +19 -19
  56. data/package/rules/index.js +15 -18
  57. data/package/rules/less.js +22 -0
  58. data/package/rules/sass.js +10 -10
  59. data/package/rules/svg.js +20 -0
  60. data/package/utils/get_style_rule.js +26 -36
  61. data/package/utils/helpers.js +26 -35
  62. data/package.json +29 -45
  63. data/test/compiler_test.rb +0 -12
  64. data/test/configuration_test.rb +1 -32
  65. data/test/dev_server_runner_test.rb +24 -5
  66. data/test/engine_rake_tasks_test.rb +39 -0
  67. data/test/helper_test.rb +24 -30
  68. data/test/mounted_app/Rakefile +4 -0
  69. data/test/mounted_app/test/dummy/Rakefile +3 -0
  70. data/test/mounted_app/test/dummy/bin/rails +3 -0
  71. data/test/mounted_app/test/dummy/bin/rake +3 -0
  72. data/test/mounted_app/test/dummy/config/application.rb +10 -0
  73. data/test/mounted_app/test/dummy/config/environment.rb +3 -0
  74. data/test/mounted_app/test/dummy/config/webpacker.yml +75 -0
  75. data/test/mounted_app/test/dummy/config.ru +5 -0
  76. data/test/mounted_app/test/dummy/package.json +7 -0
  77. data/test/rake_tasks_test.rb +1 -10
  78. data/test/test_app/config/webpacker.yml +1 -25
  79. data/test/test_app/config/webpacker_public_root.yml +0 -1
  80. data/test/test_app/public/packs/manifest.json +17 -13
  81. data/test/test_app/some.config.js +0 -0
  82. data/test/webpack_runner_test.rb +9 -3
  83. data/yarn.lock +2505 -4943
  84. metadata +37 -82
  85. data/docs/assets.md +0 -119
  86. data/docs/cloud9.md +0 -310
  87. data/docs/css.md +0 -308
  88. data/docs/deployment.md +0 -130
  89. data/docs/docker.md +0 -68
  90. data/docs/engines.md +0 -213
  91. data/docs/env.md +0 -63
  92. data/docs/es6.md +0 -72
  93. data/docs/folder-structure.md +0 -66
  94. data/docs/integrations.md +0 -220
  95. data/docs/misc.md +0 -23
  96. data/docs/props.md +0 -223
  97. data/docs/target.md +0 -22
  98. data/docs/testing.md +0 -136
  99. data/docs/troubleshooting.md +0 -158
  100. data/docs/typescript.md +0 -190
  101. data/docs/v4-upgrade.md +0 -142
  102. data/docs/webpack-dev-server.md +0 -92
  103. data/docs/webpack.md +0 -364
  104. data/docs/yarn.md +0 -23
  105. data/lib/install/angular.rb +0 -23
  106. data/lib/install/coffee.rb +0 -25
  107. data/lib/install/config/.browserslistrc +0 -1
  108. data/lib/install/config/babel.config.js +0 -82
  109. data/lib/install/config/postcss.config.js +0 -12
  110. data/lib/install/config/webpack/environment.js +0 -3
  111. data/lib/install/elm.rb +0 -39
  112. data/lib/install/erb.rb +0 -25
  113. data/lib/install/examples/angular/hello_angular/app/app.component.ts +0 -9
  114. data/lib/install/examples/angular/hello_angular/app/app.module.ts +0 -16
  115. data/lib/install/examples/angular/hello_angular/index.ts +0 -8
  116. data/lib/install/examples/angular/hello_angular/polyfills.ts +0 -73
  117. data/lib/install/examples/angular/hello_angular.js +0 -7
  118. data/lib/install/examples/coffee/hello_coffee.coffee +0 -4
  119. data/lib/install/examples/elm/Main.elm +0 -55
  120. data/lib/install/examples/elm/hello_elm.js +0 -16
  121. data/lib/install/examples/erb/hello_erb.js.erb +0 -6
  122. data/lib/install/examples/react/babel.config.js +0 -99
  123. data/lib/install/examples/react/hello_react.jsx +0 -26
  124. data/lib/install/examples/react/tsconfig.json +0 -21
  125. data/lib/install/examples/stimulus/application.js +0 -1
  126. data/lib/install/examples/stimulus/controllers/hello_controller.js +0 -18
  127. data/lib/install/examples/stimulus/controllers/index.js +0 -9
  128. data/lib/install/examples/svelte/app.svelte +0 -11
  129. data/lib/install/examples/svelte/hello_svelte.js +0 -20
  130. data/lib/install/examples/typescript/hello_typescript.ts +0 -4
  131. data/lib/install/examples/typescript/tsconfig.json +0 -24
  132. data/lib/install/examples/vue/app.vue +0 -22
  133. data/lib/install/examples/vue/hello_vue.js +0 -72
  134. data/lib/install/loaders/coffee.js +0 -6
  135. data/lib/install/loaders/elm.js +0 -25
  136. data/lib/install/loaders/erb.js +0 -11
  137. data/lib/install/loaders/svelte.js +0 -9
  138. data/lib/install/loaders/vue.js +0 -6
  139. data/lib/install/react.rb +0 -18
  140. data/lib/install/stimulus.rb +0 -12
  141. data/lib/install/svelte.rb +0 -29
  142. data/lib/install/typescript.rb +0 -39
  143. data/lib/install/vue.rb +0 -49
  144. data/lib/tasks/installers.rake +0 -42
  145. data/package/config_types/__tests__/config_list.js +0 -118
  146. data/package/config_types/__tests__/config_object.js +0 -43
  147. data/package/config_types/config_list.js +0 -75
  148. data/package/config_types/config_object.js +0 -55
  149. data/package/config_types/index.js +0 -7
  150. data/package/rules/module.css.js +0 -3
  151. data/package/rules/module.sass.js +0 -8
  152. data/package/rules/node_modules.js +0 -22
  153. data/package/utils/__tests__/deep_assign.js +0 -32
  154. data/package/utils/__tests__/deep_merge.js +0 -10
  155. data/package/utils/__tests__/get_style_rule.js +0 -65
  156. data/package/utils/__tests__/objectify.js +0 -9
  157. data/package/utils/deep_assign.js +0 -22
  158. data/package/utils/deep_merge.js +0 -22
  159. data/package/utils/objectify.js +0 -3
@@ -14,11 +14,6 @@ class ConfigurationTest < Webpacker::Test
14
14
  assert_equal source_path, @config.source_path.to_s
15
15
  end
16
16
 
17
- def test_source_path_globbed
18
- assert_equal @config.source_path_globbed,
19
- "app/javascript/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}"
20
- end
21
-
22
17
  def test_source_entry_path
23
18
  source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/javascript", "packs").to_s
24
19
  assert_equal @config.source_entry_path.to_s, source_entry_path
@@ -54,21 +49,7 @@ class ConfigurationTest < Webpacker::Test
54
49
  end
55
50
 
56
51
  def test_additional_paths
57
- assert_equal @config.additional_paths, ["app/assets", "/etc/yarn", "app/elm"]
58
- end
59
-
60
- def test_additional_paths_globbed
61
- assert_equal @config.additional_paths_globbed, [
62
- "app/assets/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
63
- "/etc/yarn/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
64
- "app/elm/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}"
65
- ]
66
- end
67
-
68
- def test_extensions
69
- config_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/config/webpacker.yml").to_s
70
- webpacker_yml = YAML.load_file(config_path)
71
- assert_equal @config.extensions, webpacker_yml["default"]["extensions"]
52
+ assert_equal @config.additional_paths, ["app/assets", "/etc/yarn", "some.config.js", "app/elm"]
72
53
  end
73
54
 
74
55
  def test_cache_manifest?
@@ -94,16 +75,4 @@ class ConfigurationTest < Webpacker::Test
94
75
  assert Webpacker.config.compile?
95
76
  end
96
77
  end
97
-
98
- def test_extract_css?
99
- assert @config.extract_css?
100
-
101
- with_rails_env("development") do
102
- refute Webpacker.config.extract_css?
103
- end
104
-
105
- with_rails_env("test") do
106
- refute Webpacker.config.extract_css?
107
- end
108
- end
109
78
  end
@@ -13,34 +13,53 @@ class DevServerRunnerTest < Webpacker::Test
13
13
  end
14
14
 
15
15
  def test_run_cmd_via_node_modules
16
- cmd = ["#{test_app_path}/node_modules/.bin/webpack-dev-server", "--config", "#{test_app_path}/config/webpack/development.js"]
16
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/development.js"]
17
17
 
18
18
  verify_command(cmd, use_node_modules: true)
19
19
  end
20
20
 
21
21
  def test_run_cmd_via_yarn
22
- cmd = ["yarn", "webpack-dev-server", "--config", "#{test_app_path}/config/webpack/development.js"]
22
+ cmd = ["yarn", "webpack", "serve", "--config", "#{test_app_path}/config/webpack/development.js"]
23
23
 
24
24
  verify_command(cmd, use_node_modules: false)
25
25
  end
26
26
 
27
+ def test_run_cmd_argv
28
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/development.js", "--quiet"]
29
+
30
+ verify_command(cmd, argv: ["--quiet"])
31
+ end
32
+
33
+ def test_run_cmd_argv_with_https
34
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/development.js", "--https"]
35
+
36
+ dev_server = Webpacker::DevServer.new({})
37
+ def dev_server.host; "localhost"; end
38
+ def dev_server.port; "3035"; end
39
+ def dev_server.pretty?; false; end
40
+ def dev_server.https?; true; end
41
+ Webpacker::DevServer.stub(:new, dev_server) do
42
+ verify_command(cmd, argv: ["--https"])
43
+ end
44
+ end
45
+
27
46
  private
28
47
  def test_app_path
29
48
  File.expand_path("test_app", __dir__)
30
49
  end
31
50
 
32
- def verify_command(cmd, use_node_modules: true)
51
+ def verify_command(cmd, use_node_modules: true, argv: [])
33
52
  cwd = Dir.pwd
34
53
  Dir.chdir(test_app_path)
35
54
 
36
55
  klass = Webpacker::DevServerRunner
37
- instance = klass.new([])
56
+ instance = klass.new(argv)
38
57
  mock = Minitest::Mock.new
39
58
  mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
40
59
 
41
60
  klass.stub(:new, instance) do
42
61
  instance.stub(:node_modules_bin_exist?, use_node_modules) do
43
- Kernel.stub(:exec, mock) { klass.run([]) }
62
+ Kernel.stub(:exec, mock) { klass.run(argv) }
44
63
  end
45
64
  end
46
65
 
@@ -0,0 +1,39 @@
1
+ require "test_helper"
2
+
3
+ class EngineRakeTasksTest < Minitest::Test
4
+ def setup
5
+ remove_webpack_binstubs
6
+ end
7
+
8
+ def teardown
9
+ remove_webpack_binstubs
10
+ end
11
+
12
+ def test_task_mounted
13
+ output = Dir.chdir(mounted_app_path) { `rake -T` }
14
+ assert_includes output, "app:webpacker"
15
+ end
16
+
17
+ def test_binstubs
18
+ Dir.chdir(mounted_app_path) { `bundle exec rake app:webpacker:binstubs` }
19
+ webpack_binstub_paths.each { |path| assert File.exist?(path) }
20
+ end
21
+
22
+ private
23
+ def mounted_app_path
24
+ File.expand_path("mounted_app", __dir__)
25
+ end
26
+
27
+ def webpack_binstub_paths
28
+ [
29
+ "#{mounted_app_path}/test/dummy/bin/webpack",
30
+ "#{mounted_app_path}/test/dummy/bin/webpack-dev-server",
31
+ ]
32
+ end
33
+
34
+ def remove_webpack_binstubs
35
+ webpack_binstub_paths.each do |path|
36
+ File.delete(path) if File.exist?(path)
37
+ end
38
+ end
39
+ end
data/test/helper_test.rb CHANGED
@@ -17,21 +17,27 @@ class HelperTest < ActionView::TestCase
17
17
  def test_asset_pack_path
18
18
  assert_equal "/packs/bootstrap-300631c4f0e0f9c865bc.js", asset_pack_path("bootstrap.js")
19
19
  assert_equal "/packs/bootstrap-c38deda30895059837cf.css", asset_pack_path("bootstrap.css")
20
-
21
- Webpacker.config.stub :extract_css?, false do
22
- assert_nil asset_pack_path("bootstrap.css")
23
- assert_equal "/packs/application-k344a6d59eef8632c9d1.png", asset_pack_path("application.png")
24
- end
25
20
  end
26
21
 
27
22
  def test_asset_pack_url
28
23
  assert_equal "https://example.com/packs/bootstrap-300631c4f0e0f9c865bc.js", asset_pack_url("bootstrap.js")
29
24
  assert_equal "https://example.com/packs/bootstrap-c38deda30895059837cf.css", asset_pack_url("bootstrap.css")
25
+ end
30
26
 
31
- Webpacker.config.stub :extract_css?, false do
32
- assert_nil asset_pack_path("bootstrap.css")
33
- assert_equal "https://example.com/packs/application-k344a6d59eef8632c9d1.png", asset_pack_url("application.png")
34
- end
27
+ def test_image_pack_path
28
+ assert_equal "/packs/application-k344a6d59eef8632c9d1.png", image_pack_path("application.png")
29
+ assert_equal "/packs/media/images/image-c38deda30895059837cf.jpg", image_pack_path("image.jpg")
30
+ assert_equal "/packs/media/images/image-c38deda30895059837cf.jpg", image_pack_path("media/images/image.jpg")
31
+ assert_equal "/packs/media/images/nested/image-c38deda30895059837cf.jpg", image_pack_path("nested/image.jpg")
32
+ assert_equal "/packs/media/images/nested/image-c38deda30895059837cf.jpg", image_pack_path("media/images/nested/image.jpg")
33
+ end
34
+
35
+ def test_image_pack_url
36
+ assert_equal "https://example.com/packs/application-k344a6d59eef8632c9d1.png", image_pack_url("application.png")
37
+ assert_equal "https://example.com/packs/media/images/image-c38deda30895059837cf.jpg", image_pack_url("image.jpg")
38
+ assert_equal "https://example.com/packs/media/images/image-c38deda30895059837cf.jpg", image_pack_url("media/images/image.jpg")
39
+ assert_equal "https://example.com/packs/media/images/nested/image-c38deda30895059837cf.jpg", image_pack_url("nested/image.jpg")
40
+ assert_equal "https://example.com/packs/media/images/nested/image-c38deda30895059837cf.jpg", image_pack_url("media/images/nested/image.jpg")
35
41
  end
36
42
 
37
43
  def test_image_pack_tag
@@ -117,41 +123,29 @@ class HelperTest < ActionView::TestCase
117
123
  end
118
124
 
119
125
  def test_stylesheet_pack_tag_split_chunks
120
- assert_equal stylesheet_packs_with_chunks_tag("application", "hello_stimulus").in?([
121
- %(<link rel="stylesheet" href="/packs/1-c20632e7baf2c81200d3.chunk.css" media="screen" />\n) +
122
- %(<link rel="stylesheet" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" media="screen" />\n) +
123
- %(<link rel="stylesheet" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" media="screen" />),
124
-
125
- %(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
126
+ assert_equal \
127
+ %(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
126
128
  %(<link rel="stylesheet" media="screen" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" />\n) +
127
129
  %(<link rel="stylesheet" media="screen" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" />),
128
- ]),
129
- true
130
+ stylesheet_packs_with_chunks_tag("application", "hello_stimulus")
130
131
  end
131
132
 
132
133
  def test_stylesheet_pack_tag
133
- assert_equal stylesheet_pack_tag("bootstrap.css").in?([
134
- %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="screen" />),
135
-
134
+ assert_equal \
136
135
  %(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
137
- ]), true
136
+ stylesheet_pack_tag("bootstrap.css")
138
137
  end
139
138
 
140
139
  def test_stylesheet_pack_tag_symbol
141
- assert_equal stylesheet_pack_tag(:bootstrap).in?([
142
- %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="screen" />),
143
-
140
+ assert_equal \
144
141
  %(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
145
- ]), true
142
+ stylesheet_pack_tag(:bootstrap)
146
143
  end
147
144
 
148
145
  def test_stylesheet_pack_tag_splat
149
- assert_equal stylesheet_pack_tag("bootstrap.css", "application.css", media: "all").in?([
150
- %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="all" />\n) +
151
- %(<link rel="stylesheet" href="/packs/application-dd6b1cd38bfa093df600.css" media="all" />),
152
-
146
+ assert_equal \
153
147
  %(<link rel="stylesheet" media="all" href="/packs/bootstrap-c38deda30895059837cf.css" />\n) +
154
148
  %(<link rel="stylesheet" media="all" href="/packs/application-dd6b1cd38bfa093df600.css" />),
155
- ]), true
149
+ stylesheet_pack_tag("bootstrap.css", "application.css", media: "all")
156
150
  end
157
151
  end
@@ -0,0 +1,4 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
@@ -0,0 +1,3 @@
1
+ require_relative "config/application"
2
+
3
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require "rails/commands"
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require "rake"
3
+ Rake.application.run
@@ -0,0 +1,10 @@
1
+ require "action_controller/railtie"
2
+ require "action_view/railtie"
3
+ require "webpacker"
4
+
5
+ module TestDummyApp
6
+ class Application < Rails::Application
7
+ config.secret_key_base = "abcdef"
8
+ config.eager_load = true
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ require_relative "application"
2
+
3
+ Rails.application.initialize!
@@ -0,0 +1,75 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_output_path: packs
7
+ cache_path: tmp/cache/webpacker
8
+
9
+ # Additional paths webpack should lookup modules
10
+ # ['app/assets', 'engine/foo/app/assets']
11
+ additional_paths:
12
+ - app/assets
13
+ - /etc/yarn
14
+
15
+ # Reload manifest.json on all requests so we reload latest compiled packs
16
+ cache_manifest: false
17
+
18
+ extensions:
19
+ - .js
20
+ - .sass
21
+ - .scss
22
+ - .css
23
+ - .module.sass
24
+ - .module.scss
25
+ - .module.css
26
+ - .png
27
+ - .svg
28
+ - .gif
29
+ - .jpeg
30
+ - .jpg
31
+
32
+ development:
33
+ <<: *default
34
+ compile: true
35
+
36
+ # Reference: https://webpack.js.org/configuration/dev-server/
37
+ dev_server:
38
+ https: false
39
+ host: localhost
40
+ port: 3035
41
+ public: localhost:3035
42
+ hmr: false
43
+ # Inline should be set to true if using HMR
44
+ inline: true
45
+ overlay: true
46
+ disable_host_check: true
47
+ use_local_ip: false
48
+
49
+ test:
50
+ <<: *default
51
+ compile: true
52
+
53
+ # Compile test packs to a separate directory
54
+ public_output_path: packs-test
55
+
56
+ production:
57
+ <<: *default
58
+
59
+ # Production depends on precompilation of packs prior to booting for performance.
60
+ compile: false
61
+
62
+ # Cache manifest.json for performance
63
+ cache_manifest: true
64
+
65
+ staging:
66
+ <<: *default
67
+
68
+ # Production depends on precompilation of packs prior to booting for performance.
69
+ compile: false
70
+
71
+ # Cache manifest.json for performance
72
+ cache_manifest: true
73
+
74
+ # Compile staging packs to a separate directory
75
+ public_output_path: packs-staging
@@ -0,0 +1,5 @@
1
+ # This file allows the `Rails.root` to be correctly determined.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
@@ -0,0 +1,7 @@
1
+ {
2
+ "private": true,
3
+ "dependencies": {
4
+ "@rails/webpacker": "file:../../../../"
5
+ },
6
+ "license": "MIT"
7
+ }
@@ -11,21 +11,12 @@ class RakeTasksTest < Minitest::Test
11
11
  assert_includes output, "webpacker:clobber"
12
12
  assert_includes output, "webpacker:compile"
13
13
  assert_includes output, "webpacker:install"
14
- assert_includes output, "webpacker:install:angular"
15
- assert_includes output, "webpacker:install:coffee"
16
- assert_includes output, "webpacker:install:elm"
17
- assert_includes output, "webpacker:install:erb"
18
- assert_includes output, "webpacker:install:react"
19
- assert_includes output, "webpacker:install:svelte"
20
- assert_includes output, "webpacker:install:stimulus"
21
- assert_includes output, "webpacker:install:typescript"
22
- assert_includes output, "webpacker:install:vue"
23
14
  assert_includes output, "webpacker:verify_install"
24
15
  end
25
16
 
26
17
  def test_rake_task_webpacker_check_binstubs
27
18
  output = Dir.chdir(test_app_path) { `rake webpacker:check_binstubs 2>&1` }
28
- refute_includes output, "webpack binstubs not found."
19
+ refute_includes output, "webpack binstub not found."
29
20
  end
30
21
 
31
22
  def test_check_node_version
@@ -13,18 +13,12 @@ default: &default
13
13
  additional_paths:
14
14
  - app/assets
15
15
  - /etc/yarn
16
-
17
- # This configuration option is deprecated and is only here for testing, to
18
- # ensure backwards-compatibility. Please use `additional_paths`.
19
- resolved_paths:
16
+ - some.config.js
20
17
  - app/elm
21
18
 
22
19
  # Reload manifest.json on all requests so we reload latest compiled packs
23
20
  cache_manifest: false
24
21
 
25
- # Extract and emit a css file
26
- extract_css: false
27
-
28
22
  static_assets_extensions:
29
23
  - .jpg
30
24
  - .jpeg
@@ -37,18 +31,6 @@ default: &default
37
31
  extensions:
38
32
  - .mjs
39
33
  - .js
40
- - .sass
41
- - .scss
42
- - .css
43
- - .module.sass
44
- - .module.scss
45
- - .module.css
46
- - .png
47
- - .svg
48
- - .gif
49
- - .jpeg
50
- - .jpg
51
- - .elm
52
34
 
53
35
  development:
54
36
  <<: *default
@@ -81,9 +63,6 @@ production:
81
63
  # Production depends on precompilation of packs prior to booting for performance.
82
64
  compile: false
83
65
 
84
- # Extract and emit a css file
85
- extract_css: true
86
-
87
66
  # Cache manifest.json for performance
88
67
  cache_manifest: true
89
68
 
@@ -93,9 +72,6 @@ staging:
93
72
  # Production depends on precompilation of packs prior to booting for performance.
94
73
  compile: false
95
74
 
96
- # Extract and emit a css file
97
- extract_css: true
98
-
99
75
  # Cache manifest.json for performance
100
76
  cache_manifest: true
101
77
 
@@ -15,5 +15,4 @@ test:
15
15
  production:
16
16
  <<: *default
17
17
  compile: false
18
- extract_css: true
19
18
  cache_manifest: true
@@ -12,21 +12,25 @@
12
12
  "media/images/nested/mb-icon.png": "/packs/media/images/nested/mb-icon-c38deda30895059837cf.png",
13
13
  "entrypoints": {
14
14
  "application": {
15
- "js": [
16
- "/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
17
- "/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js",
18
- "/packs/application-k344a6d59eef8632c9d1.js"
19
- ],
20
- "css": [
21
- "/packs/1-c20632e7baf2c81200d3.chunk.css",
22
- "/packs/application-k344a6d59eef8632c9d1.chunk.css"
23
- ]
15
+ "assets": {
16
+ "js": [
17
+ "/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
18
+ "/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js",
19
+ "/packs/application-k344a6d59eef8632c9d1.js"
20
+ ],
21
+ "css": [
22
+ "/packs/1-c20632e7baf2c81200d3.chunk.css",
23
+ "/packs/application-k344a6d59eef8632c9d1.chunk.css"
24
+ ]
25
+ }
24
26
  },
25
27
  "hello_stimulus": {
26
- "css": [
27
- "/packs/1-c20632e7baf2c81200d3.chunk.css",
28
- "/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css"
29
- ]
28
+ "assets": {
29
+ "css": [
30
+ "/packs/1-c20632e7baf2c81200d3.chunk.css",
31
+ "/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css"
32
+ ]
33
+ }
30
34
  }
31
35
  }
32
36
  }
File without changes
@@ -24,23 +24,29 @@ class WebpackRunnerTest < Webpacker::Test
24
24
  verify_command(cmd, use_node_modules: false)
25
25
  end
26
26
 
27
+ def test_run_cmd_argv
28
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "--config", "#{test_app_path}/config/webpack/development.js", "--watch"]
29
+
30
+ verify_command(cmd, argv: ["--watch"])
31
+ end
32
+
27
33
  private
28
34
  def test_app_path
29
35
  File.expand_path("test_app", __dir__)
30
36
  end
31
37
 
32
- def verify_command(cmd, use_node_modules: true)
38
+ def verify_command(cmd, use_node_modules: true, argv: [])
33
39
  cwd = Dir.pwd
34
40
  Dir.chdir(test_app_path)
35
41
 
36
42
  klass = Webpacker::WebpackRunner
37
- instance = klass.new([])
43
+ instance = klass.new(argv)
38
44
  mock = Minitest::Mock.new
39
45
  mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
40
46
 
41
47
  klass.stub(:new, instance) do
42
48
  instance.stub(:node_modules_bin_exist?, use_node_modules) do
43
- Kernel.stub(:exec, mock) { klass.run([]) }
49
+ Kernel.stub(:exec, mock) { klass.run(argv) }
44
50
  end
45
51
  end
46
52