Browse Source

Bump webpacker from 3.5.5 to 4.0.2 (#10277)

Bumps [webpacker](https://github.com/rails/webpacker) from 3.5.5 to 4.0.2.
- [Release notes](https://github.com/rails/webpacker/releases)
- [Changelog](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/webpacker/compare/v3.5.5...v4.0.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>
Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>
Yamagishi Kazutoshi 3 months ago
parent
commit
8347479f5d
46 changed files with 1694 additions and 1690 deletions
  1. 1
    1
      Gemfile
  2. 3
    3
      Gemfile.lock
  3. 1
    1
      app/serializers/rest/instance_serializer.rb
  4. 1
    1
      app/serializers/rss/account_serializer.rb
  5. 1
    1
      app/serializers/rss/tag_serializer.rb
  6. 2
    2
      app/views/about/more.html.haml
  7. 2
    2
      app/views/about/show.html.haml
  8. 1
    1
      app/views/application/_sidebar.html.haml
  9. 1
    1
      app/views/home/index.html.haml
  10. 1
    1
      app/views/layouts/admin.html.haml
  11. 1
    1
      app/views/layouts/auth.html.haml
  12. 2
    2
      app/views/layouts/mailer.html.haml
  13. 1
    1
      app/views/layouts/public.html.haml
  14. 1
    1
      app/views/notification_mailer/favourite.html.haml
  15. 1
    1
      app/views/notification_mailer/follow.html.haml
  16. 1
    1
      app/views/notification_mailer/follow_request.html.haml
  17. 1
    1
      app/views/notification_mailer/mention.html.haml
  18. 1
    1
      app/views/notification_mailer/reblog.html.haml
  19. 1
    1
      app/views/shared/_og.html.haml
  20. 1
    1
      app/views/user_mailer/backup_ready.html.haml
  21. 1
    1
      app/views/user_mailer/confirmation_instructions.html.haml
  22. 1
    1
      app/views/user_mailer/email_changed.html.haml
  23. 1
    1
      app/views/user_mailer/password_change.html.haml
  24. 1
    1
      app/views/user_mailer/reconfirmation_instructions.html.haml
  25. 1
    1
      app/views/user_mailer/reset_password_instructions.html.haml
  26. 1
    1
      app/views/user_mailer/warning.html.haml
  27. 1
    1
      app/views/user_mailer/welcome.html.haml
  28. 5
    1
      bin/webpack
  29. 5
    1
      bin/webpack-dev-server
  30. 1
    3
      config/webpack/configuration.js
  31. 28
    12
      config/webpack/development.js
  32. 0
    12
      config/webpack/loaders/assets.js
  33. 0
    12
      config/webpack/loaders/babel.js
  34. 0
    21
      config/webpack/loaders/babel_external.js
  35. 12
    16
      config/webpack/production.js
  36. 21
    0
      config/webpack/rules/babel.js
  37. 8
    1
      config/webpack/rules/css.js
  38. 20
    0
      config/webpack/rules/file.js
  39. 14
    0
      config/webpack/rules/index.js
  40. 0
    0
      config/webpack/rules/mark.js
  41. 26
    0
      config/webpack/rules/node_modules.js
  42. 11
    6
      config/webpack/shared.js
  43. 41
    4
      config/webpacker.yml
  44. 0
    29
      jest.config.js
  45. 53
    27
      package.json
  46. 1417
    1513
      yarn.lock

+ 1
- 1
Gemfile View File

@@ -86,7 +86,7 @@ gem 'tty-command', '~> 0.8', require: false
86 86
 gem 'tty-prompt', '~> 0.18', require: false
87 87
 gem 'twitter-text', '~> 1.14'
88 88
 gem 'tzinfo-data', '~> 1.2018'
89
-gem 'webpacker', '~> 3.5'
89
+gem 'webpacker', '~> 4.0'
90 90
 gem 'webpush'
91 91
 
92 92
 gem 'json-ld', '~> 3.0'

+ 3
- 3
Gemfile.lock View File

@@ -433,7 +433,7 @@ GEM
433 433
     rack-cors (1.0.2)
434 434
     rack-protection (2.0.5)
435 435
       rack
436
-    rack-proxy (0.6.4)
436
+    rack-proxy (0.6.5)
437 437
       rack
438 438
     rack-test (1.1.0)
439 439
       rack (>= 1.0, < 3)
@@ -640,7 +640,7 @@ GEM
640 640
       addressable (>= 2.3.6)
641 641
       crack (>= 0.3.2)
642 642
       hashdiff
643
-    webpacker (3.5.5)
643
+    webpacker (4.0.2)
644 644
       activesupport (>= 4.2)
645 645
       rack-proxy (>= 0.6.1)
646 646
       railties (>= 4.2)
@@ -772,7 +772,7 @@ DEPENDENCIES
772 772
   twitter-text (~> 1.14)
773 773
   tzinfo-data (~> 1.2018)
774 774
   webmock (~> 3.5)
775
-  webpacker (~> 3.5)
775
+  webpacker (~> 4.0)
776 776
   webpush
777 777
 
778 778
 RUBY VERSION

+ 1
- 1
app/serializers/rest/instance_serializer.rb View File

@@ -32,7 +32,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
32 32
   end
33 33
 
34 34
   def thumbnail
35
-    instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('preview.jpg')
35
+    instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('media/images/preview.jpg')
36 36
   end
37 37
 
38 38
   def stats

+ 1
- 1
app/serializers/rss/account_serializer.rb View File

@@ -11,7 +11,7 @@ class RSS::AccountSerializer
11 11
     builder.title("#{display_name(account)} (@#{account.local_username_and_domain})")
12 12
            .description(account_description(account))
13 13
            .link(TagManager.instance.url_for(account))
14
-           .logo(full_asset_url(asset_pack_path('logo.svg')))
14
+           .logo(full_pack_url('media/images/logo.svg'))
15 15
            .accent_color('2b90d9')
16 16
 
17 17
     builder.image(full_asset_url(account.avatar.url(:original))) if account.avatar?

+ 1
- 1
app/serializers/rss/tag_serializer.rb View File

@@ -12,7 +12,7 @@ class RSS::TagSerializer
12 12
     builder.title("##{tag.name}")
13 13
            .description(strip_tags(I18n.t('about.about_hashtag_html', hashtag: tag.name)))
14 14
            .link(tag_url(tag))
15
-           .logo(full_asset_url(asset_pack_path('logo.svg')))
15
+           .logo(full_pack_url('media/images/logo.svg'))
16 16
            .accent_color('2b90d9')
17 17
 
18 18
     statuses.each do |status|

+ 2
- 2
app/views/about/more.html.haml View File

@@ -9,7 +9,7 @@
9 9
   .column-0
10 10
     .public-account-header.public-account-header--no-bar
11 11
       .public-account-header__image
12
-        = image_tag @instance_presenter.hero&.file&.url || @instance_presenter.thumbnail&.file&.url || asset_pack_path('preview.jpg'), alt: @instance_presenter.site_title, class: 'parallax'
12
+        = image_tag @instance_presenter.hero&.file&.url || @instance_presenter.thumbnail&.file&.url || asset_pack_path('media/images/preview.jpg'), alt: @instance_presenter.site_title, class: 'parallax'
13 13
 
14 14
   .column-1
15 15
     .landing-page__call-to-action{ dir: 'ltr' }
@@ -25,7 +25,7 @@
25 25
             %span= t 'about.status_count_after', count: @instance_presenter.status_count
26 26
         .row__mascot
27 27
           .landing-page__mascot
28
-            = image_tag @instance_presenter.mascot&.file&.url || asset_pack_path('elephant_ui_plane.svg'), alt: ''
28
+            = image_tag @instance_presenter.mascot&.file&.url || asset_pack_path('media/images/elephant_ui_plane.svg'), alt: ''
29 29
 
30 30
   .column-2
31 31
     .landing-page__information.contact-widget

+ 2
- 2
app/views/about/show.html.haml View File

@@ -8,7 +8,7 @@
8 8
 .landing
9 9
   .landing__brand
10 10
     = link_to root_url, class: 'brand' do
11
-      = image_tag asset_pack_path('logo_full.svg'), alt: 'Mastodon'
11
+      = image_pack_tag 'logo_full.svg', alt: 'Mastodon'
12 12
       %span.brand__tagline=t 'about.tagline'
13 13
 
14 14
   .landing__grid
@@ -48,7 +48,7 @@
48 48
 
49 49
       .hero-widget
50 50
         .hero-widget__img
51
-          = image_tag @instance_presenter.hero&.file&.url || @instance_presenter.thumbnail&.file&.url || asset_pack_path('preview.jpg'), alt: @instance_presenter.site_title
51
+          = image_tag @instance_presenter.hero&.file&.url || @instance_presenter.thumbnail&.file&.url || asset_pack_path('media/images/preview.jpg'), alt: @instance_presenter.site_title
52 52
 
53 53
         - if @instance_presenter.site_short_description.present?
54 54
           .hero-widget__text

+ 1
- 1
app/views/application/_sidebar.html.haml View File

@@ -1,6 +1,6 @@
1 1
 .hero-widget
2 2
   .hero-widget__img
3
-    = image_tag @instance_presenter.hero&.file&.url || @instance_presenter.thumbnail&.file&.url || asset_pack_path('preview.jpg'), alt: @instance_presenter.site_title
3
+    = image_tag @instance_presenter.hero&.file&.url || @instance_presenter.thumbnail&.file&.url || asset_pack_path('media/images/preview.jpg'), alt: @instance_presenter.site_title
4 4
 
5 5
   .hero-widget__text
6 6
     %p= @instance_presenter.site_short_description.html_safe.presence || @instance_presenter.site_description.html_safe.presence || t('about.generic_description', domain: site_hostname)

+ 1
- 1
app/views/home/index.html.haml View File

@@ -11,7 +11,7 @@
11 11
 
12 12
 .app-holder#mastodon{ data: { props: Oj.dump(default_props) } }
13 13
   %noscript
14
-    = image_tag asset_pack_path('logo.svg'), alt: 'Mastodon'
14
+    = image_pack_tag 'logo.svg', alt: 'Mastodon'
15 15
 
16 16
     %div
17 17
       = t('errors.noscript_html', apps_path: 'https://joinmastodon.org/apps')

+ 1
- 1
app/views/layouts/admin.html.haml View File

@@ -6,7 +6,7 @@
6 6
     .sidebar-wrapper
7 7
       .sidebar
8 8
         = link_to root_path do
9
-          = image_tag asset_pack_path('logo.svg'), class: 'logo', alt: 'Mastodon'
9
+          = image_pack_tag 'logo.svg', class: 'logo', alt: 'Mastodon'
10 10
 
11 11
         = render_navigation
12 12
     .content-wrapper

+ 1
- 1
app/views/layouts/auth.html.haml View File

@@ -6,7 +6,7 @@
6 6
     .logo-container
7 7
       %h1
8 8
         = link_to root_path do
9
-          = image_tag asset_pack_path('logo_full.svg'), alt: 'Mastodon'
9
+          = image_pack_tag 'logo_full.svg', alt: 'Mastodon'
10 10
 
11 11
     .form-container
12 12
       = render 'flashes'

+ 2
- 2
app/views/layouts/mailer.html.haml View File

@@ -24,7 +24,7 @@
24 24
                               %tr
25 25
                                 %td.column-cell
26 26
                                   = link_to root_url do
27
-                                    = image_tag full_pack_url('logo_full.png'), alt: 'Mastodon', height: 34, class: 'logo'
27
+                                    = image_tag full_pack_url('media/images/mailer/logo_full.png'), alt: 'Mastodon', height: 34, class: 'logo'
28 28
 
29 29
     = yield
30 30
 
@@ -49,4 +49,4 @@
49 49
                                 %p= link_to t('application_mailer.notification_preferences'), settings_notifications_url
50 50
                               %td.column-cell.text-right
51 51
                                 = link_to root_url do
52
-                                  = image_tag full_pack_url('logo_transparent.png'), alt: 'Mastodon', height: 24
52
+                                  = image_tag full_pack_url('media/images/mailer/logo_transparent.png'), alt: 'Mastodon', height: 24

+ 1
- 1
app/views/layouts/public.html.haml View File

@@ -8,7 +8,7 @@
8 8
         %nav.header
9 9
           .nav-left
10 10
             = link_to root_url, class: 'brand' do
11
-              = image_tag asset_pack_path('logo_full.svg'), alt: 'Mastodon'
11
+              = image_pack_tag 'logo_full.svg', alt: 'Mastodon'
12 12
 
13 13
             = link_to t('directories.directory'), explore_path, class: 'nav-link optional' if Setting.profile_directory
14 14
             = link_to t('about.about_this'), about_more_path, class: 'nav-link optional'

+ 1
- 1
app/views/notification_mailer/favourite.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_grade.png'), alt:''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_grade.png'), alt:''
21 21
 
22 22
                               %h1= t 'notification_mailer.favourite.title'
23 23
                               %p.lead= t('notification_mailer.favourite.body', name: @account.acct)

+ 1
- 1
app/views/notification_mailer/follow.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_person_add.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_person_add.png'), alt: ''
21 21
 
22 22
                               %h1= t 'notification_mailer.follow.title'
23 23
                               %p.lead= t('notification_mailer.follow.body', name: @account.acct)

+ 1
- 1
app/views/notification_mailer/follow_request.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_person_add.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_person_add.png'), alt: ''
21 21
 
22 22
                               %h1= t 'notification_mailer.follow_request.title'
23 23
                               %p.lead= t('notification_mailer.follow_request.body', name: @account.acct)

+ 1
- 1
app/views/notification_mailer/mention.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_reply.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_reply.png'), alt: ''
21 21
 
22 22
                               %h1= t 'notification_mailer.mention.title'
23 23
                               %p.lead= t('notification_mailer.mention.body', name: @status.account.acct)

+ 1
- 1
app/views/notification_mailer/reblog.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_cached.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_cached.png'), alt: ''
21 21
 
22 22
                               %h1= t 'notification_mailer.reblog.title'
23 23
                               %p.lead= t('notification_mailer.reblog.body', name: @account.acct)

+ 1
- 1
app/views/shared/_og.html.haml View File

@@ -8,7 +8,7 @@
8 8
 = opengraph 'og:type', 'website'
9 9
 = opengraph 'og:title', @instance_presenter.site_title
10 10
 = opengraph 'og:description', description
11
-= opengraph 'og:image', full_asset_url(thumbnail&.file&.url || asset_pack_path('preview.jpg', protocol: :request))
11
+= opengraph 'og:image', full_asset_url(thumbnail&.file&.url || asset_pack_path('media/images/preview.jpg', protocol: :request))
12 12
 = opengraph 'og:image:width', thumbnail ? thumbnail.meta['width'] : '1200'
13 13
 = opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '630'
14 14
 = opengraph 'twitter:card', 'summary_large_image'

+ 1
- 1
app/views/user_mailer/backup_ready.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_file_download.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_file_download.png'), alt: ''
21 21
 
22 22
                               %h1= t 'user_mailer.backup_ready.title'
23 23
 

+ 1
- 1
app/views/user_mailer/confirmation_instructions.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_email.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_email.png'), alt: ''
21 21
 
22 22
                               %h1= t 'devise.mailer.confirmation_instructions.title'
23 23
 

+ 1
- 1
app/views/user_mailer/email_changed.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_email.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_email.png'), alt: ''
21 21
 
22 22
                               %h1= t 'devise.mailer.email_changed.title'
23 23
                               %p.lead= t 'devise.mailer.email_changed.explanation'

+ 1
- 1
app/views/user_mailer/password_change.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_lock_open.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_lock_open.png'), alt: ''
21 21
 
22 22
                               %h1= t 'devise.mailer.password_change.title'
23 23
                               %p.lead= t 'devise.mailer.password_change.explanation'

+ 1
- 1
app/views/user_mailer/reconfirmation_instructions.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_email.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_email.png'), alt: ''
21 21
 
22 22
                               %h1= t 'devise.mailer.reconfirmation_instructions.title'
23 23
                               %p.lead= t 'devise.mailer.reconfirmation_instructions.explanation'

+ 1
- 1
app/views/user_mailer/reset_password_instructions.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_lock_open.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_lock_open.png'), alt: ''
21 21
 
22 22
                               %h1= t 'devise.mailer.reset_password_instructions.title'
23 23
                               %p.lead= t 'devise.mailer.reset_password_instructions.explanation'

+ 1
- 1
app/views/user_mailer/warning.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_warning.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_warning.png'), alt: ''
21 21
 
22 22
                               %h1= t "user_mailer.warning.title.#{@warning.action}"
23 23
 

+ 1
- 1
app/views/user_mailer/welcome.html.haml View File

@@ -17,7 +17,7 @@
17 17
                                 %tbody
18 18
                                   %tr
19 19
                                     %td
20
-                                      = image_tag full_pack_url('icon_done.png'), alt: ''
20
+                                      = image_tag full_pack_url('media/images/mailer/icon_done.png'), alt: ''
21 21
 
22 22
                               %h1= t 'user_mailer.welcome.title', name: @resource.account.username
23 23
                               %p.lead= t 'user_mailer.welcome.explanation'

+ 5
- 1
bin/webpack View File

@@ -12,4 +12,8 @@ require "bundler/setup"
12 12
 
13 13
 require "webpacker"
14 14
 require "webpacker/webpack_runner"
15
-Webpacker::WebpackRunner.run(ARGV)
15
+
16
+APP_ROOT = File.expand_path("..", __dir__)
17
+Dir.chdir(APP_ROOT) do
18
+  Webpacker::WebpackRunner.run(ARGV)
19
+end

+ 5
- 1
bin/webpack-dev-server View File

@@ -12,4 +12,8 @@ require "bundler/setup"
12 12
 
13 13
 require "webpacker"
14 14
 require "webpacker/dev_server_runner"
15
-Webpacker::DevServerRunner.run(ARGV)
15
+
16
+APP_ROOT = File.expand_path("..", __dir__)
17
+Dir.chdir(APP_ROOT) do
18
+  Webpacker::DevServerRunner.run(ARGV)
19
+end

+ 1
- 3
config/webpack/configuration.js View File

@@ -1,12 +1,11 @@
1 1
 // Common configuration for webpacker loaded from config/webpacker.yml
2 2
 
3
-const { join, resolve } = require('path');
3
+const { resolve } = require('path');
4 4
 const { env } = require('process');
5 5
 const { safeLoad } = require('js-yaml');
6 6
 const { readFileSync } = require('fs');
7 7
 
8 8
 const configPath = resolve('config', 'webpacker.yml');
9
-const loadersDir = join(__dirname, 'loaders');
10 9
 const settings = safeLoad(readFileSync(configPath), 'utf8')[env.RAILS_ENV || env.NODE_ENV];
11 10
 
12 11
 const themePath = resolve('config', 'themes.yml');
@@ -37,6 +36,5 @@ module.exports = {
37 36
     CDN_HOST: env.CDN_HOST,
38 37
     NODE_ENV: env.NODE_ENV,
39 38
   },
40
-  loadersDir,
41 39
   output,
42 40
 };

+ 28
- 12
config/webpack/development.js View File

@@ -1,12 +1,10 @@
1 1
 // Note: You must restart bin/webpack-dev-server for changes to take effect
2 2
 
3 3
 const merge = require('webpack-merge');
4
-const sharedConfig = require('./shared.js');
5
-const { settings, output } = require('./configuration.js');
4
+const sharedConfig = require('./shared');
5
+const { settings, output } = require('./configuration');
6 6
 
7
-const watchOptions = {
8
-  ignored: /node_modules/,
9
-};
7
+const watchOptions = {};
10 8
 
11 9
 if (process.env.VAGRANT) {
12 10
   // If we are in Vagrant, we can't rely on inotify to update us with changed
@@ -17,7 +15,7 @@ if (process.env.VAGRANT) {
17 15
 
18 16
 module.exports = merge(sharedConfig, {
19 17
   mode: 'development',
20
-
18
+  cache: true,
21 19
   devtool: 'cheap-module-eval-source-map',
22 20
 
23 21
   stats: {
@@ -30,15 +28,33 @@ module.exports = merge(sharedConfig, {
30 28
 
31 29
   devServer: {
32 30
     clientLogLevel: 'none',
33
-    https: settings.dev_server.https,
31
+    compress: settings.dev_server.compress,
32
+    quiet: settings.dev_server.quiet,
33
+    disableHostCheck: settings.dev_server.disable_host_check,
34 34
     host: settings.dev_server.host,
35 35
     port: settings.dev_server.port,
36
+    https: settings.dev_server.https,
37
+    hot: settings.dev_server.hmr,
36 38
     contentBase: output.path,
39
+    inline: settings.dev_server.inline,
40
+    useLocalIp: settings.dev_server.use_local_ip,
41
+    public: settings.dev_server.public,
37 42
     publicPath: output.publicPath,
38
-    compress: true,
39
-    headers: { 'Access-Control-Allow-Origin': '*' },
40
-    historyApiFallback: true,
41
-    disableHostCheck: true,
42
-    watchOptions: watchOptions,
43
+    historyApiFallback: {
44
+      disableDotRule: true,
45
+    },
46
+    headers: settings.dev_server.headers,
47
+    overlay: settings.dev_server.overlay,
48
+    stats: {
49
+      entrypoints: false,
50
+      errorDetails: false,
51
+      modules: false,
52
+      moduleTrace: false,
53
+    },
54
+    watchOptions: Object.assign(
55
+      {},
56
+      settings.dev_server.watch_options,
57
+      watchOptions
58
+    ),
43 59
   },
44 60
 });

+ 0
- 12
config/webpack/loaders/assets.js View File

@@ -1,12 +0,0 @@
1
-const { env, publicPath } = require('../configuration.js');
2
-
3
-module.exports = {
4
-  test: /\.(jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i,
5
-  use: [{
6
-    loader: 'file-loader',
7
-    options: {
8
-      publicPath,
9
-      name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]',
10
-    },
11
-  }],
12
-};

+ 0
- 12
config/webpack/loaders/babel.js View File

@@ -1,12 +0,0 @@
1
-const { resolve } = require('path');
2
-
3
-const env = process.env.NODE_ENV || 'development';
4
-
5
-module.exports = {
6
-  test: /\.js$/,
7
-  exclude: /node_modules/,
8
-  loader: 'babel-loader',
9
-  options: {
10
-    cacheDirectory: env === 'development' ? false : resolve(__dirname, '..', '..', '..', 'tmp', 'cache', 'babel-loader'),
11
-  },
12
-};

+ 0
- 21
config/webpack/loaders/babel_external.js View File

@@ -1,21 +0,0 @@
1
-const { resolve } = require('path');
2
-
3
-const env = process.env.NODE_ENV || 'development';
4
-
5
-if (env === 'development') {
6
-  module.exports = {};
7
-} else {
8
-  // babel options to apply only to external libraries, e.g. remove-prop-types
9
-  module.exports = {
10
-    test: /\.js$/,
11
-    include: /node_modules/,
12
-    loader: 'babel-loader',
13
-    options: {
14
-      babelrc: false,
15
-      plugins: [
16
-        'transform-react-remove-prop-types',
17
-      ],
18
-      cacheDirectory: env === 'development' ? false : resolve(__dirname, '..', '..', '..', 'tmp', 'cache', 'babel-loader-external'),
19
-    },
20
-  };
21
-}

+ 12
- 16
config/webpack/production.js View File

@@ -1,15 +1,15 @@
1 1
 // Note: You must restart bin/webpack-dev-server for changes to take effect
2 2
 
3
+const path = require('path');
4
+const { URL } = require('url');
3 5
 const merge = require('webpack-merge');
6
+const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
7
+const OfflinePlugin = require('offline-plugin');
4 8
 const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
5 9
 const CompressionPlugin = require('compression-webpack-plugin');
6 10
 const zopfli = require('@gfx/zopfli');
7
-const sharedConfig = require('./shared.js');
8
-const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
9
-const OfflinePlugin = require('offline-plugin');
10
-const { publicPath } = require('./configuration.js');
11
-const path = require('path');
12
-const { URL } = require('url');
11
+const { output } = require('./configuration');
12
+const sharedConfig = require('./shared');
13 13
 
14 14
 let attachmentHost;
15 15
 
@@ -28,15 +28,9 @@ if (process.env.S3_ENABLED === 'true') {
28 28
 
29 29
 module.exports = merge(sharedConfig, {
30 30
   mode: 'production',
31
-
32
-  output: {
33
-    filename: '[name]-[chunkhash].js',
34
-    chunkFilename: '[name]-[chunkhash].js',
35
-  },
36
-
37
-  devtool: 'source-map', // separate sourcemap file, suitable for production
31
+  devtool: 'source-map',
38 32
   stats: 'normal',
39
-
33
+  bail: true,
40 34
   optimization: {
41 35
     minimize: true,
42 36
     minimizer: [
@@ -60,10 +54,12 @@ module.exports = merge(sharedConfig, {
60 54
 
61 55
   plugins: [
62 56
     new CompressionPlugin({
57
+      filename: '[path].gz[query]',
63 58
       algorithm(input, compressionOptions, callback) {
64 59
         return zopfli.gzip(input, compressionOptions, callback);
65 60
       },
66
-      test: /\.(js|css|html|json|ico|svg|eot|otf|ttf)$/,
61
+      cache: true,
62
+      test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/,
67 63
     }),
68 64
     new BundleAnalyzerPlugin({ // generates report.html and stats.json
69 65
       analyzerMode: 'static',
@@ -76,7 +72,7 @@ module.exports = merge(sharedConfig, {
76 72
       logLevel: 'silent', // do not bother Webpacker, who runs with --json and parses stdout
77 73
     }),
78 74
     new OfflinePlugin({
79
-      publicPath: publicPath, // sw.js must be served from the root to avoid scope issues
75
+      publicPath: output.publicPath, // sw.js must be served from the root to avoid scope issues
80 76
       caches: {
81 77
         main: [':rest:'],
82 78
         additional: [':externals:'],

+ 21
- 0
config/webpack/rules/babel.js View File

@@ -0,0 +1,21 @@
1
+const { join, resolve } = require('path');
2
+const { env, settings } = require('../configuration');
3
+
4
+module.exports = {
5
+  test: /\.(js|jsx|mjs)$/,
6
+  include: [
7
+    settings.source_path,
8
+    ...settings.resolved_paths,
9
+  ].map(p => resolve(p)),
10
+  exclude: /node_modules/,
11
+  use: [
12
+    {
13
+      loader: 'babel-loader',
14
+      options: {
15
+        cacheDirectory: join(settings.cache_path, 'babel-loader'),
16
+        cacheCompression: env.NODE_ENV === 'production',
17
+        compact: env.NODE_ENV === 'production',
18
+      },
19
+    },
20
+  ],
21
+};

config/webpack/loaders/sass.js → config/webpack/rules/css.js View File

@@ -4,7 +4,14 @@ module.exports = {
4 4
   test: /\.s?css$/i,
5 5
   use: [
6 6
     MiniCssExtractPlugin.loader,
7
-    'css-loader',
7
+    {
8
+      loader: 'css-loader',
9
+      options: {
10
+        sourceMap: true,
11
+        importLoaders: 2,
12
+        localIdentName: '[name]__[local]___[hash:base64:5]',
13
+      },
14
+    },
8 15
     {
9 16
       loader: 'postcss-loader',
10 17
       options: {

+ 20
- 0
config/webpack/rules/file.js View File

@@ -0,0 +1,20 @@
1
+const { join } = require('path');
2
+const { settings } = require('../configuration');
3
+
4
+module.exports = {
5
+  test: new RegExp(`(${settings.static_assets_extensions.join('|')})$`, 'i'),
6
+  use: [
7
+    {
8
+      loader: 'file-loader',
9
+      options: {
10
+        name(file) {
11
+          if (file.includes(settings.source_path)) {
12
+            return 'media/[path][name]-[hash].[ext]';
13
+          }
14
+          return 'media/[folder]/[name]-[hash:8].[ext]';
15
+        },
16
+        context: join(settings.source_path),
17
+      },
18
+    },
19
+  ],
20
+};

+ 14
- 0
config/webpack/rules/index.js View File

@@ -0,0 +1,14 @@
1
+const babel = require('./babel');
2
+const css = require('./css');
3
+const file = require('./file');
4
+const nodeModules = require('./node_modules');
5
+
6
+// Webpack loaders are processed in reverse order
7
+// https://webpack.js.org/concepts/loaders/#loader-features
8
+// Lastly, process static files using file loader
9
+module.exports = {
10
+  file,
11
+  css,
12
+  nodeModules,
13
+  babel,
14
+};

config/webpack/loaders/mark.js → config/webpack/rules/mark.js View File


+ 26
- 0
config/webpack/rules/node_modules.js View File

@@ -0,0 +1,26 @@
1
+const { join } = require('path');
2
+const { settings, env } = require('../configuration');
3
+
4
+module.exports = {
5
+  test: /\.(js|mjs)$/,
6
+  include: /node_modules/,
7
+  exclude: /@babel(?:\/|\\{1,2})runtime/,
8
+  use: [
9
+    {
10
+      loader: 'babel-loader',
11
+      options: {
12
+        babelrc: false,
13
+        presets: [
14
+          ['@babel/env', { modules: false }],
15
+        ],
16
+        plugins: [
17
+          'transform-react-remove-prop-types',
18
+        ],
19
+        cacheDirectory: join(settings.cache_path, 'babel-loader-node-modules'),
20
+        cacheCompression: env.NODE_ENV === 'production',
21
+        compact: false,
22
+        sourceMaps: false,
23
+      },
24
+    },
25
+  ],
26
+};

+ 11
- 6
config/webpack/shared.js View File

@@ -6,7 +6,8 @@ const { sync } = require('glob');
6 6
 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7 7
 const AssetsManifestPlugin = require('webpack-assets-manifest');
8 8
 const extname = require('path-complete-extname');
9
-const { env, settings, themes, output, loadersDir } = require('./configuration.js');
9
+const { env, settings, themes, output } = require('./configuration');
10
+const rules = require('./rules');
10 11
 const localePackPaths = require('./generateLocalePacks');
11 12
 
12 13
 const extensionGlob = `**/*{${settings.extensions.join(',')}}*`;
@@ -33,8 +34,9 @@ module.exports = {
33 34
   ),
34 35
 
35 36
   output: {
36
-    filename: '[name].js',
37
-    chunkFilename: '[name].js',
37
+    filename: 'js/[name]-[chunkhash].js',
38
+    chunkFilename: 'js/[name]-[chunkhash].chunk.js',
39
+    hotUpdateChunkFilename: 'js/[id]-[hash].hot-update.js',
38 40
     path: output.path,
39 41
     publicPath: output.publicPath,
40 42
   },
@@ -60,7 +62,7 @@ module.exports = {
60 62
   },
61 63
 
62 64
   module: {
63
-    rules: sync(join(loadersDir, '*.js')).map(loader => require(loader)),
65
+    rules: Object.keys(rules).map(key => rules[key]),
64 66
   },
65 67
 
66 68
   plugins: [
@@ -73,11 +75,14 @@ module.exports = {
73 75
       }
74 76
     ),
75 77
     new MiniCssExtractPlugin({
76
-      filename: env.NODE_ENV === 'production' ? '[name]-[contenthash].css' : '[name].css',
78
+      filename: 'css/[name]-[contenthash:8].css',
79
+      chunkFilename: 'css/[name]-[contenthash:8].chunk.css',
77 80
     }),
78 81
     new AssetsManifestPlugin({
79
-      publicPath: true,
82
+      integrity: false,
83
+      entrypoints: true,
80 84
       writeToDisk: true,
85
+      publicPath: true,
81 86
     }),
82 87
   ],
83 88
 

+ 41
- 4
config/webpacker.yml View File

@@ -3,8 +3,11 @@
3 3
 default: &default
4 4
   source_path: app/javascript
5 5
   source_entry_path: packs
6
+  public_root_path: public
6 7
   public_output_path: packs
7 8
   cache_path: tmp/cache/webpacker
9
+  check_yarn_integrity: false
10
+  webpack_compile_output: false
8 11
 
9 12
   # Additional paths webpack should lookup modules
10 13
   # ['app/assets', 'engine/foo/app/assets']
@@ -13,11 +16,31 @@ default: &default
13 16
   # Reload manifest.json on all requests so we reload latest compiled packs
14 17
   cache_manifest: false
15 18
 
19
+  # Extract and emit a css file
20
+  extract_css: true
21
+
22
+  static_assets_extensions:
23
+    - .jpg
24
+    - .jpeg
25
+    - .png
26
+    - .tiff
27
+    - .ico
28
+    - .svg
29
+    - .eot
30
+    - .otf
31
+    - .ttf
32
+    - .woff
33
+    - .woff2
34
+
16 35
   extensions:
36
+    - .mjs
17 37
     - .js
18 38
     - .sass
19 39
     - .scss
20 40
     - .css
41
+    - .module.sass
42
+    - .module.scss
43
+    - .module.css
21 44
     - .png
22 45
     - .svg
23 46
     - .gif
@@ -26,24 +49,38 @@ default: &default
26 49
 
27 50
 development:
28 51
   <<: *default
52
+
29 53
   compile: true
30 54
 
55
+  # Reference: https://webpack.js.org/configuration/dev-server/
31 56
   dev_server:
57
+    https: false
32 58
     host: localhost
33 59
     port: 3035
60
+    public: localhost:3035
34 61
     hmr: false
35
-    https: false
62
+    # Inline should be set to true if using HMR
63
+    inline: true
64
+    overlay: true
65
+    compress: true
66
+    disable_host_check: true
67
+    use_local_ip: false
68
+    quiet: false
69
+    headers:
70
+      'Access-Control-Allow-Origin': '*'
71
+    watch_options:
72
+      ignored: '**/node_modules/**'
36 73
 
37 74
 test:
38 75
   <<: *default
39 76
 
40
-  # Compile test packs to a separate directory
41
-  public_output_path: packs-test
42
-
43 77
   # CircleCI precompiles packs prior to running the tests.
44 78
   # Also avoids race conditions in parallel_tests.
45 79
   compile: false
46 80
 
81
+  # Compile test packs to a separate directory
82
+  public_output_path: packs-test
83
+
47 84
 production:
48 85
   <<: *default
49 86
 

+ 0
- 29
jest.config.js View File

@@ -1,29 +0,0 @@
1
-module.exports = {
2
-  projects: [
3
-    '<rootDir>/app/javascript/mastodon',
4
-  ],
5
-  testPathIgnorePatterns: [
6
-    '<rootDir>/node_modules/',
7
-    '<rootDir>/vendor/',
8
-    '<rootDir>/config/',
9
-    '<rootDir>/log/',
10
-    '<rootDir>/public/',
11
-    '<rootDir>/tmp/',
12
-  ],
13
-  setupFiles: [
14
-    'raf/polyfill',
15
-  ],
16
-  setupTestFrameworkScriptFile: '<rootDir>/app/javascript/mastodon/test_setup.js',
17
-  collectCoverageFrom: [
18
-    'app/javascript/mastodon/**/*.js',
19
-    '!app/javascript/mastodon/features/emoji/emoji_compressed.js',
20
-    '!app/javascript/mastodon/locales/locale-data/*.js',
21
-    '!app/javascript/mastodon/service_worker/entry.js',
22
-    '!app/javascript/mastodon/test_setup.js',
23
-  ],
24
-  coverageDirectory: '<rootDir>/coverage',
25
-  moduleDirectories: [
26
-    '<rootDir>/node_modules',
27
-    '<rootDir>/app/javascript',
28
-  ],
29
-};

+ 53
- 27
package.json View File

@@ -24,36 +24,66 @@
24 24
     "iOS >= 9",
25 25
     "not dead"
26 26
   ],
27
+  "jest": {
28
+    "projects": [
29
+      "<rootDir>/app/javascript/mastodon"
30
+    ],
31
+    "testPathIgnorePatterns": [
32
+      "<rootDir>/node_modules/",
33
+      "<rootDir>/vendor/",
34
+      "<rootDir>/config/",
35
+      "<rootDir>/log/",
36
+      "<rootDir>/public/",
37
+      "<rootDir>/tmp/"
38
+    ],
39
+    "setupFiles": [
40
+      "raf/polyfill"
41
+    ],
42
+    "setupFilesAfterEnv": [
43
+      "<rootDir>/app/javascript/mastodon/test_setup.js"
44
+    ],
45
+    "collectCoverageFrom": [
46
+      "app/javascript/mastodon/**/*.js",
47
+      "!app/javascript/mastodon/features/emoji/emoji_compressed.js",
48
+      "!app/javascript/mastodon/locales/locale-data/*.js",
49
+      "!app/javascript/mastodon/service_worker/entry.js",
50
+      "!app/javascript/mastodon/test_setup.js"
51
+    ],
52
+    "coverageDirectory": "<rootDir>/coverage",
53
+    "moduleDirectories": [
54
+      "<rootDir>/node_modules",
55
+      "<rootDir>/app/javascript"
56
+    ]
57
+  },
27 58
   "private": true,
28 59
   "dependencies": {
29
-    "@babel/core": "^7.2.2",
30
-    "@babel/plugin-proposal-class-properties": "^7.2.3",
31
-    "@babel/plugin-proposal-decorators": "^7.2.3",
32
-    "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
60
+    "@babel/core": "^7.3.4",
61
+    "@babel/plugin-proposal-class-properties": "^7.3.4",
62
+    "@babel/plugin-proposal-decorators": "^7.3.0",
63
+    "@babel/plugin-proposal-object-rest-spread": "^7.3.4",
33 64
     "@babel/plugin-syntax-dynamic-import": "^7.2.0",
34 65
     "@babel/plugin-transform-react-inline-elements": "^7.2.0",
35 66
     "@babel/plugin-transform-react-jsx-self": "^7.2.0",
36 67
     "@babel/plugin-transform-react-jsx-source": "^7.2.0",
37
-    "@babel/plugin-transform-runtime": "^7.2.0",
38
-    "@babel/preset-env": "^7.2.3",
68
+    "@babel/plugin-transform-runtime": "^7.3.4",
69
+    "@babel/preset-env": "^7.3.4",
39 70
     "@babel/preset-react": "^7.0.0",
40
-    "@babel/runtime": "^7.2.0",
41
-    "@gfx/zopfli": "^1.0.10",
71
+    "@babel/runtime": "^7.3.4",
72
+    "@gfx/zopfli": "^1.0.11",
42 73
     "array-includes": "^3.0.3",
43
-    "autoprefixer": "^9.4.3",
74
+    "autoprefixer": "^9.4.10",
44 75
     "axios": "^0.18.0",
45
-    "babel-core": "^7.0.0-bridge.0",
46
-    "babel-loader": "^8.0.4",
76
+    "babel-loader": "^8.0.5",
47 77
     "babel-plugin-lodash": "^3.3.4",
48 78
     "babel-plugin-preval": "^3.0.1",
49 79
     "babel-plugin-react-intl": "^3.0.1",
50
-    "babel-plugin-transform-react-remove-prop-types": "^0.4.21",
80
+    "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
51 81
     "babel-runtime": "^6.26.0",
52 82
     "classnames": "^2.2.5",
53 83
     "compression-webpack-plugin": "^2.0.0",
54 84
     "cross-env": "^5.1.4",
55
-    "css-loader": "^2.1.0",
56
-    "cssnano": "^4.1.8",
85
+    "css-loader": "^2.1.1",
86
+    "cssnano": "^4.1.10",
57 87
     "detect-passive-events": "^1.0.2",
58 88
     "dotenv": "^6.2.0",
59 89
     "emoji-mart": "Gargron/emoji-mart#build",
@@ -119,26 +149,25 @@
119 149
     "requestidlecallback": "^0.3.0",
120 150
     "reselect": "^4.0.0",
121 151
     "rimraf": "^2.6.1",
122
-    "sass": "^1.15.2",
152
+    "sass": "^1.17.2",
123 153
     "sass-loader": "^7.0.3",
124 154
     "stringz": "^1.0.0",
125
-    "style-loader": "0.23.1",
126 155
     "substring-trie": "^1.0.2",
127 156
     "throng": "^4.0.0",
128 157
     "tiny-queue": "^0.2.1",
129
-    "uglifyjs-webpack-plugin": "^2.1.1",
158
+    "uglifyjs-webpack-plugin": "^2.1.2",
130 159
     "uuid": "^3.1.0",
131 160
     "uws": "10.148.0",
132
-    "webpack": "^4.28.3",
161
+    "webpack": "^4.29.6",
133 162
     "webpack-assets-manifest": "^3.1.1",
134
-    "webpack-bundle-analyzer": "^3.0.3",
135
-    "webpack-cli": "^3.1.2",
136
-    "webpack-merge": "^4.1.5",
163
+    "webpack-bundle-analyzer": "^3.1.0",
164
+    "webpack-cli": "^3.2.3",
165
+    "webpack-merge": "^4.2.1",
137 166
     "websocket.js": "^0.1.12"
138 167
   },
139 168
   "devDependencies": {
140 169
     "babel-eslint": "^10.0.1",
141
-    "babel-jest": "^23.6.0",
170
+    "babel-jest": "^24.5.0",
142 171
     "enzyme": "^3.8.0",
143 172
     "enzyme-adapter-react-16": "^1.7.1",
144 173
     "eslint": "^5.11.1",
@@ -146,14 +175,11 @@
146 175
     "eslint-plugin-jsx-a11y": "~6.1.2",
147 176
     "eslint-plugin-promise": "~4.0.1",
148 177
     "eslint-plugin-react": "~7.12.1",
149
-    "jest": "^23.6.0",
178
+    "jest": "^24.5.0",
150 179
     "raf": "^3.4.1",
151 180
     "react-intl-translations-manager": "^5.0.3",
152 181
     "react-test-renderer": "^16.7.0",
153
-    "webpack-dev-server": "^3.1.14",
182
+    "webpack-dev-server": "^3.2.1",
154 183
     "yargs": "^12.0.5"
155
-  },
156
-  "optionalDependencies": {
157
-    "fsevents": "*"
158 184
   }
159 185
 }

+ 1417
- 1513
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save