diff --git a/.github/workflows/test-ruby.yml b/.github/workflows/test-ruby.yml index 1f7f8f93a8b..46ebe58bc58 100644 --- a/.github/workflows/test-ruby.yml +++ b/.github/workflows/test-ruby.yml @@ -49,7 +49,6 @@ jobs: public/assets public/packs public/packs-test - tmp/cache/webpacker key: ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }} restore-keys: | ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }} diff --git a/Gemfile b/Gemfile index 9e5955e0b83..f857c391848 100644 --- a/Gemfile +++ b/Gemfile @@ -95,7 +95,6 @@ gem 'tty-prompt', '~> 0.23', require: false gem 'twitter-text', '~> 3.1.0' gem 'tzinfo-data', '~> 1.2023' gem 'webauthn', '~> 3.0' -gem 'webpacker', '~> 5.4' gem 'webpush', github: 'mastodon/webpush', ref: '9631ac63045cfabddacc69fc06e919b4c13eb913' gem 'json-ld' @@ -230,3 +229,5 @@ gem 'rubyzip', '~> 2.3' gem 'hcaptcha', '~> 7.1' gem 'mail', '~> 2.8' + +gem 'vite_rails', '~> 3.0.19' diff --git a/Gemfile.lock b/Gemfile.lock index f12647a403c..4d1216d322e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -203,6 +203,7 @@ GEM railties (>= 5) dotenv (3.1.8) drb (2.2.1) + dry-cli (1.2.0) elasticsearch (7.17.11) elasticsearch-api (= 7.17.11) elasticsearch-transport (= 7.17.11) @@ -803,7 +804,6 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - semantic_range (3.1.0) shoulda-matchers (6.4.0) activesupport (>= 5.2.0) sidekiq (6.5.12) @@ -889,6 +889,15 @@ GEM validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix + vite_rails (3.0.19) + railties (>= 5.1, < 9) + vite_ruby (~> 3.0, >= 3.2.2) + vite_ruby (3.9.2) + dry-cli (>= 0.7, < 2) + logger (~> 1.6) + mutex_m + rack-proxy (~> 0.6, >= 0.6.1) + zeitwerk (~> 2.2) warden (1.2.9) rack (>= 2.0.9) webauthn (3.4.0) @@ -907,11 +916,6 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webpacker (5.4.4) - activesupport (>= 5.2) - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) webrick (1.9.1) websocket (1.2.11) websocket-driver (0.7.7) @@ -1075,9 +1079,9 @@ DEPENDENCIES tty-prompt (~> 0.23) twitter-text (~> 3.1.0) tzinfo-data (~> 1.2023) + vite_rails (~> 3.0.19) webauthn (~> 3.0) webmock (~> 3.18) - webpacker (~> 5.4) webpush! xorcist (~> 1.1) diff --git a/app/helpers/routing_helper.rb b/app/helpers/routing_helper.rb index 22efc5f0924..1ff8b992c3e 100644 --- a/app/helpers/routing_helper.rb +++ b/app/helpers/routing_helper.rb @@ -4,7 +4,7 @@ module RoutingHelper extend ActiveSupport::Concern include ActionView::Helpers::AssetTagHelper - include Webpacker::Helper + include ViteRails::TagHelpers included do include Rails.application.routes.url_helpers @@ -25,7 +25,7 @@ module RoutingHelper end def frontend_asset_path(source, **) - asset_pack_path("media/#{source}", **) + vite_asset_path(source, **) end def frontend_asset_url(source, **) diff --git a/app/helpers/theme_helper.rb b/app/helpers/theme_helper.rb index cda380b3bc0..158ac92d6da 100644 --- a/app/helpers/theme_helper.rb +++ b/app/helpers/theme_helper.rb @@ -4,11 +4,14 @@ module ThemeHelper def theme_style_tags(theme) if theme == 'system' ''.html_safe.tap do |tags| - tags << stylesheet_pack_tag('mastodon-light', media: 'not all and (prefers-color-scheme: dark)', crossorigin: 'anonymous') - tags << stylesheet_pack_tag('default', media: '(prefers-color-scheme: dark)', crossorigin: 'anonymous') + tags << vite_stylesheet_tag('styles/mastodon-light.scss', media: 'not all and (prefers-color-scheme: dark)', crossorigin: 'anonymous') + tags << vite_stylesheet_tag('styles/application.scss', media: '(prefers-color-scheme: dark)', crossorigin: 'anonymous') end + # TODO: Determine why default doesn't map correctly. + elsif theme == 'default' + vite_stylesheet_tag 'styles/application.scss', media: 'all', crossorigin: 'anonymous' else - stylesheet_pack_tag theme, media: 'all', crossorigin: 'anonymous' + vite_stylesheet_tag "styles/#{theme}.scss", media: 'all', crossorigin: 'anonymous' end end diff --git a/app/javascript/mastodon/features/alt_text_modal/index.tsx b/app/javascript/mastodon/features/alt_text_modal/index.tsx index e2d05a99ca4..773170eaa84 100644 --- a/app/javascript/mastodon/features/alt_text_modal/index.tsx +++ b/app/javascript/mastodon/features/alt_text_modal/index.tsx @@ -16,9 +16,9 @@ import { useSpring, animated } from '@react-spring/web'; import Textarea from 'react-textarea-autosize'; import { length } from 'stringz'; // eslint-disable-next-line import/extensions -import tesseractWorkerPath from 'tesseract.js/dist/worker.min.js'; +import tesseractWorkerPath from 'tesseract.js/dist/worker.min.js?url'; // eslint-disable-next-line import/no-extraneous-dependencies -import tesseractCorePath from 'tesseract.js-core/tesseract-core.wasm.js'; +import tesseractCorePath from 'tesseract.js-core/tesseract-core.wasm.js?url'; import { showAlertForError } from 'mastodon/actions/alerts'; import { uploadThumbnail } from 'mastodon/actions/compose'; @@ -351,8 +351,8 @@ export const AltTextModal = forwardRef>( fetchTesseract() .then(async ({ createWorker }) => { const worker = await createWorker('eng', 1, { - workerPath: tesseractWorkerPath as string, - corePath: tesseractCorePath as string, + workerPath: tesseractWorkerPath, + corePath: tesseractCorePath, langPath: `${assetHost}/ocr/lang-data`, cacheMethod: 'write', }); @@ -501,5 +501,4 @@ export const AltTextModal = forwardRef>( ); }, ); - AltTextModal.displayName = 'AltTextModal'; diff --git a/app/views/auth/sessions/two_factor.html.haml b/app/views/auth/sessions/two_factor.html.haml index 653f1558018..38def20fc5d 100644 --- a/app/views/auth/sessions/two_factor.html.haml +++ b/app/views/auth/sessions/two_factor.html.haml @@ -1,7 +1,7 @@ - content_for :page_title do = t('auth.login') -= javascript_pack_tag 'two_factor_authentication', crossorigin: 'anonymous' += vite_typescript_tag 'two_factor_authentication.ts', crossorigin: 'anonymous' - if webauthn_enabled? = render partial: 'auth/sessions/two_factor/webauthn_form', locals: { hidden: @scheme_type != 'webauthn' } diff --git a/app/views/auth/setup/show.html.haml b/app/views/auth/setup/show.html.haml index 91654ca2147..83e0bfd25f9 100644 --- a/app/views/auth/setup/show.html.haml +++ b/app/views/auth/setup/show.html.haml @@ -1,7 +1,7 @@ - content_for :page_title do = t('auth.setup.title') -= javascript_pack_tag 'sign_up', crossorigin: 'anonymous' += vite_typescript_tag 'sign_up.ts', crossorigin: 'anonymous' = simple_form_for(@user, url: auth_setup_path) do |f| = render 'auth/shared/progress', stage: 'confirm' diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 3f7727cdfb1..08432a177c0 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -1,7 +1,7 @@ - content_for :header_tags do = render_initial_state - = javascript_pack_tag 'public', crossorigin: 'anonymous' - = javascript_pack_tag 'admin', async: true, crossorigin: 'anonymous' + = vite_typescript_tag 'public.tsx', crossorigin: 'anonymous' + = vite_typescript_tag 'admin.tsx', crossorigin: 'anonymous' - content_for :body_classes, 'admin' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 6f016c6cf52..690a610bf39 100755 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -26,11 +26,12 @@ %title= html_title = theme_style_tags current_theme + = vite_client_tag + = vite_react_refresh_tag -# Needed for the wicg-inert polyfill. It needs to be on it's own