webpacker 5.2.1 → 6.0.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +1 -1
  3. data/.gitignore +2 -0
  4. data/.node-version +1 -1
  5. data/.rubocop.yml +11 -16
  6. data/CHANGELOG.md +15 -4
  7. data/CONTRIBUTING.md +1 -1
  8. data/Gemfile.lock +17 -11
  9. data/README.md +8 -4
  10. data/docs/assets.md +21 -5
  11. data/docs/css.md +24 -29
  12. data/docs/deployment.md +18 -0
  13. data/docs/docker.md +2 -2
  14. data/docs/engines.md +1 -1
  15. data/docs/env.md +5 -0
  16. data/docs/es6.md +1 -1
  17. data/docs/integrations.md +1 -1
  18. data/docs/props.md +2 -38
  19. data/docs/react.md +183 -0
  20. data/docs/testing.md +11 -0
  21. data/docs/typescript.md +2 -2
  22. data/docs/webpack-dev-server.md +17 -15
  23. data/docs/webpack.md +58 -107
  24. data/lib/install/config/webpack/base.js +3 -0
  25. data/lib/install/config/webpack/development.js +2 -2
  26. data/lib/install/config/webpack/production.js +2 -2
  27. data/lib/install/config/webpack/test.js +2 -2
  28. data/lib/install/config/webpacker.yml +8 -37
  29. data/lib/install/examples/{vue → vue3}/app.vue +10 -5
  30. data/lib/install/examples/vue3/hello_vue.js +15 -0
  31. data/lib/install/javascript/packs/application.css +9 -0
  32. data/lib/install/template.rb +33 -19
  33. data/lib/tasks/webpacker.rake +2 -11
  34. data/lib/tasks/webpacker/binstubs.rake +6 -4
  35. data/lib/tasks/webpacker/check_binstubs.rake +4 -4
  36. data/lib/tasks/webpacker/check_yarn.rake +1 -2
  37. data/lib/tasks/webpacker/compile.rake +4 -2
  38. data/lib/tasks/webpacker/info.rake +12 -10
  39. data/lib/tasks/webpacker/install.rake +6 -4
  40. data/lib/tasks/webpacker/verify_install.rake +2 -1
  41. data/lib/tasks/webpacker/yarn_install.rake +9 -1
  42. data/lib/webpacker/commands.rb +1 -1
  43. data/lib/webpacker/compiler.rb +7 -6
  44. data/lib/webpacker/configuration.rb +6 -30
  45. data/lib/webpacker/dev_server_runner.rb +21 -2
  46. data/lib/webpacker/helper.rb +22 -32
  47. data/lib/webpacker/manifest.rb +1 -1
  48. data/lib/webpacker/version.rb +1 -1
  49. data/lib/webpacker/webpack_runner.rb +5 -0
  50. data/package.json +23 -39
  51. data/package/__tests__/config.js +5 -37
  52. data/package/__tests__/development.js +9 -11
  53. data/package/__tests__/env.js +12 -4
  54. data/package/__tests__/production.js +6 -6
  55. data/package/__tests__/staging.js +7 -6
  56. data/package/__tests__/test.js +4 -5
  57. data/package/babel/preset-react.js +62 -0
  58. data/package/babel/preset.js +44 -0
  59. data/package/config.js +3 -11
  60. data/package/env.js +8 -2
  61. data/package/environments/__tests__/base.js +15 -47
  62. data/package/environments/base.js +66 -126
  63. data/package/environments/development.js +45 -44
  64. data/package/environments/production.js +69 -65
  65. data/package/environments/test.js +2 -2
  66. data/package/index.js +6 -6
  67. data/package/rules/babel.js +9 -7
  68. data/package/rules/coffee.js +6 -0
  69. data/package/rules/erb.js +13 -0
  70. data/package/rules/file.js +19 -19
  71. data/package/rules/index.js +24 -18
  72. data/package/rules/less.js +18 -0
  73. data/package/rules/sass.js +5 -6
  74. data/package/rules/svg.js +23 -0
  75. data/package/utils/get_style_rule.js +22 -28
  76. data/package/utils/helpers.js +3 -35
  77. data/test/compiler_test.rb +0 -12
  78. data/test/configuration_test.rb +1 -32
  79. data/test/dev_server_runner_test.rb +24 -5
  80. data/test/engine_rake_tasks_test.rb +39 -0
  81. data/test/helper_test.rb +15 -9
  82. data/test/mounted_app/Rakefile +4 -0
  83. data/test/mounted_app/test/dummy/Rakefile +3 -0
  84. data/test/mounted_app/test/dummy/bin/rails +3 -0
  85. data/test/mounted_app/test/dummy/bin/rake +3 -0
  86. data/test/mounted_app/test/dummy/config.ru +5 -0
  87. data/test/mounted_app/test/dummy/config/application.rb +10 -0
  88. data/test/mounted_app/test/dummy/config/environment.rb +3 -0
  89. data/test/mounted_app/test/dummy/config/webpacker.yml +75 -0
  90. data/test/mounted_app/test/dummy/package.json +7 -0
  91. data/test/rake_tasks_test.rb +1 -10
  92. data/test/test_app/config/webpacker.yml +1 -25
  93. data/test/test_app/config/webpacker_public_root.yml +0 -1
  94. data/test/test_app/public/packs/manifest.json +17 -13
  95. data/test/test_app/some.config.js +0 -0
  96. data/test/webpack_runner_test.rb +9 -3
  97. data/webpacker.gemspec +1 -1
  98. data/yarn.lock +1858 -4915
  99. metadata +47 -70
  100. data/.travis.yml +0 -43
  101. data/lib/install/angular.rb +0 -23
  102. data/lib/install/coffee.rb +0 -25
  103. data/lib/install/config/.browserslistrc +0 -1
  104. data/lib/install/config/babel.config.js +0 -70
  105. data/lib/install/config/postcss.config.js +0 -12
  106. data/lib/install/config/webpack/environment.js +0 -3
  107. data/lib/install/elm.rb +0 -39
  108. data/lib/install/erb.rb +0 -25
  109. data/lib/install/examples/angular/hello_angular.js +0 -7
  110. data/lib/install/examples/angular/hello_angular/app/app.component.ts +0 -9
  111. data/lib/install/examples/angular/hello_angular/app/app.module.ts +0 -16
  112. data/lib/install/examples/angular/hello_angular/index.ts +0 -8
  113. data/lib/install/examples/angular/hello_angular/polyfills.ts +0 -73
  114. data/lib/install/examples/coffee/hello_coffee.coffee +0 -4
  115. data/lib/install/examples/elm/Main.elm +0 -55
  116. data/lib/install/examples/elm/hello_elm.js +0 -16
  117. data/lib/install/examples/erb/hello_erb.js.erb +0 -6
  118. data/lib/install/examples/react/babel.config.js +0 -87
  119. data/lib/install/examples/react/hello_react.jsx +0 -26
  120. data/lib/install/examples/react/tsconfig.json +0 -21
  121. data/lib/install/examples/stimulus/application.js +0 -1
  122. data/lib/install/examples/stimulus/controllers/hello_controller.js +0 -18
  123. data/lib/install/examples/stimulus/controllers/index.js +0 -9
  124. data/lib/install/examples/svelte/app.svelte +0 -11
  125. data/lib/install/examples/svelte/hello_svelte.js +0 -20
  126. data/lib/install/examples/typescript/hello_typescript.ts +0 -4
  127. data/lib/install/examples/typescript/tsconfig.json +0 -24
  128. data/lib/install/examples/vue/hello_vue.js +0 -72
  129. data/lib/install/loaders/coffee.js +0 -6
  130. data/lib/install/loaders/elm.js +0 -25
  131. data/lib/install/loaders/erb.js +0 -11
  132. data/lib/install/loaders/svelte.js +0 -9
  133. data/lib/install/loaders/vue.js +0 -6
  134. data/lib/install/react.rb +0 -18
  135. data/lib/install/stimulus.rb +0 -12
  136. data/lib/install/svelte.rb +0 -29
  137. data/lib/install/typescript.rb +0 -39
  138. data/lib/install/vue.rb +0 -49
  139. data/lib/tasks/installers.rake +0 -42
  140. data/package/config_types/__tests__/config_list.js +0 -118
  141. data/package/config_types/__tests__/config_object.js +0 -43
  142. data/package/config_types/config_list.js +0 -75
  143. data/package/config_types/config_object.js +0 -55
  144. data/package/config_types/index.js +0 -7
  145. data/package/rules/module.css.js +0 -3
  146. data/package/rules/module.sass.js +0 -8
  147. data/package/rules/node_modules.js +0 -22
  148. data/package/utils/__tests__/deep_assign.js +0 -32
  149. data/package/utils/__tests__/deep_merge.js +0 -10
  150. data/package/utils/__tests__/get_style_rule.js +0 -65
  151. data/package/utils/__tests__/objectify.js +0 -9
  152. data/package/utils/deep_assign.js +0 -22
  153. data/package/utils/deep_merge.js +0 -22
  154. data/package/utils/objectify.js +0 -3
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 6.0.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  - Gaurav Tiwari
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-17 00:00:00.000000000 Z
12
+ date: 2020-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -85,16 +85,16 @@ dependencies:
85
85
  name: rubocop
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "<"
88
+ - - '='
89
89
  - !ruby/object:Gem::Version
90
- version: '0.69'
90
+ version: 0.93.1
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "<"
95
+ - - '='
96
96
  - !ruby/object:Gem::Version
97
- version: '0.69'
97
+ version: 0.93.1
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rubocop-performance
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ dependencies:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
- description:
112
+ description:
113
113
  email:
114
114
  - david@basecamp.com
115
115
  - gaurav@gauravtiwari.co.uk
@@ -126,7 +126,6 @@ files:
126
126
  - ".gitignore"
127
127
  - ".node-version"
128
128
  - ".rubocop.yml"
129
- - ".travis.yml"
130
129
  - CHANGELOG.md
131
130
  - CONTRIBUTING.md
132
131
  - Gemfile
@@ -146,6 +145,7 @@ files:
146
145
  - docs/integrations.md
147
146
  - docs/misc.md
148
147
  - docs/props.md
148
+ - docs/react.md
149
149
  - docs/target.md
150
150
  - docs/testing.md
151
151
  - docs/troubleshooting.md
@@ -157,55 +157,19 @@ files:
157
157
  - gemfiles/Gemfile-rails-edge
158
158
  - gemfiles/Gemfile-rails.5.2.x
159
159
  - gemfiles/Gemfile-rails.6.0.x
160
- - lib/install/angular.rb
161
160
  - lib/install/bin/webpack
162
161
  - lib/install/bin/webpack-dev-server
163
162
  - lib/install/binstubs.rb
164
- - lib/install/coffee.rb
165
- - lib/install/config/.browserslistrc
166
- - lib/install/config/babel.config.js
167
- - lib/install/config/postcss.config.js
163
+ - lib/install/config/webpack/base.js
168
164
  - lib/install/config/webpack/development.js
169
- - lib/install/config/webpack/environment.js
170
165
  - lib/install/config/webpack/production.js
171
166
  - lib/install/config/webpack/test.js
172
167
  - lib/install/config/webpacker.yml
173
- - lib/install/elm.rb
174
- - lib/install/erb.rb
175
- - lib/install/examples/angular/hello_angular.js
176
- - lib/install/examples/angular/hello_angular/app/app.component.ts
177
- - lib/install/examples/angular/hello_angular/app/app.module.ts
178
- - lib/install/examples/angular/hello_angular/index.ts
179
- - lib/install/examples/angular/hello_angular/polyfills.ts
180
- - lib/install/examples/coffee/hello_coffee.coffee
181
- - lib/install/examples/elm/Main.elm
182
- - lib/install/examples/elm/hello_elm.js
183
- - lib/install/examples/erb/hello_erb.js.erb
184
- - lib/install/examples/react/babel.config.js
185
- - lib/install/examples/react/hello_react.jsx
186
- - lib/install/examples/react/tsconfig.json
187
- - lib/install/examples/stimulus/application.js
188
- - lib/install/examples/stimulus/controllers/hello_controller.js
189
- - lib/install/examples/stimulus/controllers/index.js
190
- - lib/install/examples/svelte/app.svelte
191
- - lib/install/examples/svelte/hello_svelte.js
192
- - lib/install/examples/typescript/hello_typescript.ts
193
- - lib/install/examples/typescript/tsconfig.json
194
- - lib/install/examples/vue/app.vue
195
- - lib/install/examples/vue/hello_vue.js
168
+ - lib/install/examples/vue3/app.vue
169
+ - lib/install/examples/vue3/hello_vue.js
170
+ - lib/install/javascript/packs/application.css
196
171
  - lib/install/javascript/packs/application.js
197
- - lib/install/loaders/coffee.js
198
- - lib/install/loaders/elm.js
199
- - lib/install/loaders/erb.js
200
- - lib/install/loaders/svelte.js
201
- - lib/install/loaders/vue.js
202
- - lib/install/react.rb
203
- - lib/install/stimulus.rb
204
- - lib/install/svelte.rb
205
172
  - lib/install/template.rb
206
- - lib/install/typescript.rb
207
- - lib/install/vue.rb
208
- - lib/tasks/installers.rake
209
173
  - lib/tasks/webpacker.rake
210
174
  - lib/tasks/webpacker/binstubs.rake
211
175
  - lib/tasks/webpacker/check_binstubs.rake
@@ -241,13 +205,10 @@ files:
241
205
  - package/__tests__/production.js
242
206
  - package/__tests__/staging.js
243
207
  - package/__tests__/test.js
208
+ - package/babel/preset-react.js
209
+ - package/babel/preset.js
244
210
  - package/config.js
245
211
  - package/configPath.js
246
- - package/config_types/__tests__/config_list.js
247
- - package/config_types/__tests__/config_object.js
248
- - package/config_types/config_list.js
249
- - package/config_types/config_object.js
250
- - package/config_types/index.js
251
212
  - package/dev_server.js
252
213
  - package/env.js
253
214
  - package/environments/__tests__/base.js
@@ -257,30 +218,34 @@ files:
257
218
  - package/environments/test.js
258
219
  - package/index.js
259
220
  - package/rules/babel.js
221
+ - package/rules/coffee.js
260
222
  - package/rules/css.js
223
+ - package/rules/erb.js
261
224
  - package/rules/file.js
262
225
  - package/rules/index.js
263
- - package/rules/module.css.js
264
- - package/rules/module.sass.js
265
- - package/rules/node_modules.js
226
+ - package/rules/less.js
266
227
  - package/rules/sass.js
267
- - package/utils/__tests__/deep_assign.js
268
- - package/utils/__tests__/deep_merge.js
269
- - package/utils/__tests__/get_style_rule.js
270
- - package/utils/__tests__/objectify.js
271
- - package/utils/deep_assign.js
272
- - package/utils/deep_merge.js
228
+ - package/rules/svg.js
273
229
  - package/utils/get_style_rule.js
274
230
  - package/utils/helpers.js
275
- - package/utils/objectify.js
276
231
  - test/command_test.rb
277
232
  - test/compiler_test.rb
278
233
  - test/configuration_test.rb
279
234
  - test/dev_server_runner_test.rb
280
235
  - test/dev_server_test.rb
236
+ - test/engine_rake_tasks_test.rb
281
237
  - test/env_test.rb
282
238
  - test/helper_test.rb
283
239
  - test/manifest_test.rb
240
+ - test/mounted_app/Rakefile
241
+ - test/mounted_app/test/dummy/Rakefile
242
+ - test/mounted_app/test/dummy/bin/rails
243
+ - test/mounted_app/test/dummy/bin/rake
244
+ - test/mounted_app/test/dummy/config.ru
245
+ - test/mounted_app/test/dummy/config/application.rb
246
+ - test/mounted_app/test/dummy/config/environment.rb
247
+ - test/mounted_app/test/dummy/config/webpacker.yml
248
+ - test/mounted_app/test/dummy/package.json
284
249
  - test/rake_tasks_test.rb
285
250
  - test/test_app/Rakefile
286
251
  - test/test_app/app/javascript/packs/application.js
@@ -296,6 +261,7 @@ files:
296
261
  - test/test_app/config/webpacker_public_root.yml
297
262
  - test/test_app/package.json
298
263
  - test/test_app/public/packs/manifest.json
264
+ - test/test_app/some.config.js
299
265
  - test/test_app/yarn.lock
300
266
  - test/test_helper.rb
301
267
  - test/webpack_runner_test.rb
@@ -306,9 +272,9 @@ homepage: https://github.com/rails/webpacker
306
272
  licenses:
307
273
  - MIT
308
274
  metadata:
309
- source_code_uri: https://github.com/rails/webpacker/tree/v5.2.1
310
- changelog_uri: https://github.com/rails/webpacker/blob/v5.2.1/CHANGELOG.md
311
- post_install_message:
275
+ source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.pre.1
276
+ changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.pre.1/CHANGELOG.md
277
+ post_install_message:
312
278
  rdoc_options: []
313
279
  require_paths:
314
280
  - lib
@@ -319,12 +285,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
319
285
  version: 2.4.0
320
286
  required_rubygems_version: !ruby/object:Gem::Requirement
321
287
  requirements:
322
- - - ">="
288
+ - - ">"
323
289
  - !ruby/object:Gem::Version
324
- version: '0'
290
+ version: 1.3.1
325
291
  requirements: []
326
292
  rubygems_version: 3.0.3
327
- signing_key:
293
+ signing_key:
328
294
  specification_version: 4
329
295
  summary: Use webpack to manage app-like JavaScript modules in Rails
330
296
  test_files:
@@ -333,9 +299,19 @@ test_files:
333
299
  - test/configuration_test.rb
334
300
  - test/dev_server_runner_test.rb
335
301
  - test/dev_server_test.rb
302
+ - test/engine_rake_tasks_test.rb
336
303
  - test/env_test.rb
337
304
  - test/helper_test.rb
338
305
  - test/manifest_test.rb
306
+ - test/mounted_app/Rakefile
307
+ - test/mounted_app/test/dummy/Rakefile
308
+ - test/mounted_app/test/dummy/bin/rails
309
+ - test/mounted_app/test/dummy/bin/rake
310
+ - test/mounted_app/test/dummy/config.ru
311
+ - test/mounted_app/test/dummy/config/application.rb
312
+ - test/mounted_app/test/dummy/config/environment.rb
313
+ - test/mounted_app/test/dummy/config/webpacker.yml
314
+ - test/mounted_app/test/dummy/package.json
339
315
  - test/rake_tasks_test.rb
340
316
  - test/test_app/Rakefile
341
317
  - test/test_app/app/javascript/packs/application.js
@@ -351,6 +327,7 @@ test_files:
351
327
  - test/test_app/config/webpacker_public_root.yml
352
328
  - test/test_app/package.json
353
329
  - test/test_app/public/packs/manifest.json
330
+ - test/test_app/some.config.js
354
331
  - test/test_app/yarn.lock
355
332
  - test/test_helper.rb
356
333
  - test/webpack_runner_test.rb
@@ -1,43 +0,0 @@
1
- language: ruby
2
- dist: xenial
3
- before_install:
4
- - gem install rubygems-update && update_rubygems
5
- - yes | rvm @global do gem install bundler -v 2.1.4 || true
6
- rvm:
7
- - 2.4.9
8
- - 2.5.5
9
- - 2.6.5
10
- - 2.7.0
11
- - ruby-head
12
- gemfile:
13
- - gemfiles/Gemfile-rails.5.2.x
14
- - gemfiles/Gemfile-rails.6.0.x
15
- - gemfiles/Gemfile-rails-edge
16
- cache:
17
- bundler: true
18
- directories:
19
- - node_modules
20
- yarn: true
21
-
22
- install:
23
- - bundle install --jobs 3 --retry 3
24
- - nvm install 12
25
- - node -v
26
- - npm i -g yarn
27
- - yarn
28
- script:
29
- - yarn lint
30
- - yarn test
31
- - bundle exec rubocop
32
- - bundle exec rake test
33
- matrix:
34
- allow_failures:
35
- - gemfile: gemfiles/Gemfile-rails-edge
36
- - rvm: ruby-head
37
- exclude:
38
- - rvm: 2.4.9
39
- gemfile: gemfiles/Gemfile-rails-edge
40
- - rvm: 2.5.5
41
- gemfile: gemfiles/Gemfile-rails-edge
42
- - rvm: 2.4.9
43
- gemfile: gemfiles/Gemfile-rails.6.0.x
@@ -1,23 +0,0 @@
1
- require "webpacker/configuration"
2
-
3
- say "Copying angular example entry file to #{Webpacker.config.source_entry_path}"
4
- copy_file "#{__dir__}/examples/angular/hello_angular.js", "#{Webpacker.config.source_entry_path}/hello_angular.js"
5
-
6
- say "Copying hello_angular app to #{Webpacker.config.source_path}"
7
- directory "#{__dir__}/examples/angular/hello_angular", "#{Webpacker.config.source_path}/hello_angular"
8
-
9
- say "Installing all angular dependencies"
10
- run "yarn add core-js zone.js rxjs @angular/core @angular/common @angular/compiler @angular/platform-browser @angular/platform-browser-dynamic"
11
-
12
- if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
13
- say "You need to enable unsafe-eval rule.", :yellow
14
- say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
15
- say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
16
- say "if Rails.env.development?", :yellow
17
- say " policy.script_src :self, :https, :unsafe_eval", :yellow
18
- say "else", :yellow
19
- say " policy.script_src :self, :https", :yellow
20
- say "end", :yellow
21
- end
22
-
23
- say "Webpacker now supports angular 🎉", :green
@@ -1,25 +0,0 @@
1
- require "webpacker/configuration"
2
-
3
- say "Copying coffee loader to config/webpack/loaders"
4
- copy_file "#{__dir__}/loaders/coffee.js", Rails.root.join("config/webpack/loaders/coffee.js").to_s
5
-
6
- say "Adding coffee loader to config/webpack/environment.js"
7
- insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
8
- "const coffee = require('./loaders/coffee')\n",
9
- after: /require\(('|")@rails\/webpacker\1\);?\n/
10
-
11
- insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
12
- "environment.loaders.prepend('coffee', coffee)\n",
13
- before: "module.exports"
14
-
15
- say "Updating webpack paths to include .coffee file extension"
16
- insert_into_file Webpacker.config.config_path, "- .coffee\n".indent(4), after: /\s+extensions:\n/
17
-
18
- say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
19
- copy_file "#{__dir__}/examples/coffee/hello_coffee.coffee",
20
- "#{Webpacker.config.source_entry_path}/hello_coffee.coffee"
21
-
22
- say "Installing all Coffeescript dependencies"
23
- run "yarn add coffeescript@1.12.7 coffee-loader"
24
-
25
- say "Webpacker now supports Coffeescript 🎉", :green
@@ -1 +0,0 @@
1
- defaults
@@ -1,70 +0,0 @@
1
- module.exports = function(api) {
2
- var validEnv = ['development', 'test', 'production']
3
- var currentEnv = api.env()
4
- var isDevelopmentEnv = api.env('development')
5
- var isProductionEnv = api.env('production')
6
- var isTestEnv = api.env('test')
7
-
8
- if (!validEnv.includes(currentEnv)) {
9
- throw new Error(
10
- 'Please specify a valid `NODE_ENV` or ' +
11
- '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
- '"test", and "production". Instead, received: ' +
13
- JSON.stringify(currentEnv) +
14
- '.'
15
- )
16
- }
17
-
18
- return {
19
- presets: [
20
- isTestEnv && [
21
- '@babel/preset-env',
22
- {
23
- targets: {
24
- node: 'current'
25
- }
26
- }
27
- ],
28
- (isProductionEnv || isDevelopmentEnv) && [
29
- '@babel/preset-env',
30
- {
31
- forceAllTransforms: true,
32
- useBuiltIns: 'entry',
33
- corejs: 3,
34
- modules: false,
35
- exclude: ['transform-typeof-symbol']
36
- }
37
- ]
38
- ].filter(Boolean),
39
- plugins: [
40
- 'babel-plugin-macros',
41
- '@babel/plugin-syntax-dynamic-import',
42
- isTestEnv && 'babel-plugin-dynamic-import-node',
43
- '@babel/plugin-transform-destructuring',
44
- [
45
- '@babel/plugin-proposal-class-properties',
46
- {
47
- loose: true
48
- }
49
- ],
50
- [
51
- '@babel/plugin-proposal-object-rest-spread',
52
- {
53
- useBuiltIns: true
54
- }
55
- ],
56
- [
57
- '@babel/plugin-transform-runtime',
58
- {
59
- helpers: false
60
- }
61
- ],
62
- [
63
- '@babel/plugin-transform-regenerator',
64
- {
65
- async: false
66
- }
67
- ]
68
- ].filter(Boolean)
69
- }
70
- }
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- plugins: [
3
- require('postcss-import'),
4
- require('postcss-flexbugs-fixes'),
5
- require('postcss-preset-env')({
6
- autoprefixer: {
7
- flexbox: 'no-2009'
8
- },
9
- stage: 3
10
- })
11
- ]
12
- }
@@ -1,3 +0,0 @@
1
- const { environment } = require('@rails/webpacker')
2
-
3
- module.exports = environment
@@ -1,39 +0,0 @@
1
- require "webpacker/configuration"
2
-
3
- say "Copying elm loader to config/webpack/loaders"
4
- copy_file "#{__dir__}/loaders/elm.js", Rails.root.join("config/webpack/loaders/elm.js").to_s
5
-
6
- say "Adding elm loader to config/webpack/environment.js"
7
- insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
8
- "const elm = require('./loaders/elm')\n",
9
- after: /require\(('|")@rails\/webpacker\1\);?\n/
10
-
11
- insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
12
- "environment.loaders.prepend('elm', elm)\n",
13
- before: "module.exports"
14
-
15
- say "Copying Elm example entry file to #{Webpacker.config.source_entry_path}"
16
- copy_file "#{__dir__}/examples/elm/hello_elm.js",
17
- "#{Webpacker.config.source_entry_path}/hello_elm.js"
18
-
19
- say "Copying Elm app file to #{Webpacker.config.source_path}"
20
- copy_file "#{__dir__}/examples/elm/Main.elm",
21
- "#{Webpacker.config.source_path}/Main.elm"
22
-
23
- say "Installing all Elm dependencies"
24
- run "yarn add elm elm-webpack-loader"
25
- run "yarn add --dev elm-hot-webpack-loader"
26
- run "yarn run elm init"
27
- run "yarn run elm make #{Webpacker.config.source_path}/Main.elm"
28
-
29
- say "Updating webpack paths to include .elm file extension"
30
- insert_into_file Webpacker.config.config_path, "- .elm\n".indent(4), after: /\s+extensions:\n/
31
-
32
- say "Updating Elm source location"
33
- gsub_file "elm.json", /\"src\"\n/,
34
- %("#{Webpacker.config.source_path.relative_path_from(Rails.root)}"\n)
35
-
36
- say "Updating .gitignore to include elm-stuff folder"
37
- insert_into_file ".gitignore", "/elm-stuff\n", before: "/node_modules\n"
38
-
39
- say "Webpacker now supports Elm 🎉", :green