diff --git a/.gitignore b/.gitignore index 73ada7f4c7d..efcb4365403 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ .generators *.pyc *.rbc -*.sassc **.orig .bundle .byebug_history diff --git a/Gemfile b/Gemfile index 6b671ec27e0..ce251aa8a5e 100644 --- a/Gemfile +++ b/Gemfile @@ -44,6 +44,7 @@ gem 'pg' gem 'phonelib' gem 'premailer-rails', '>= 1.11.1' gem 'profanity_filter' +gem 'propshaft' gem 'rack', '>= 2.2.3.1' gem 'rack-attack', '>= 6.2.1' gem 'rack-cors', '>= 1.0.5', require: 'rack/cors' @@ -61,7 +62,6 @@ gem 'safe_target_blank', '>= 1.0.2' gem 'saml_idp', github: '18F/saml_idp', tag: '0.18.2-18f' gem 'scrypt' gem 'simple_form', '>= 5.0.2' -gem 'sprockets-rails' gem 'stringex', require: false gem 'strong_migrations', '>= 0.4.2' gem 'subprocess', require: false @@ -85,6 +85,7 @@ group :development do gem 'guard-rspec', require: false gem 'irb' gem 'letter_opener', '~> 1.8' + gem 'listen' gem 'octokit', '>= 4.25.0' gem 'rack-mini-profiler', '>= 1.1.3', require: false gem 'rails-erd', '>= 1.6.0' diff --git a/Gemfile.lock b/Gemfile.lock index 4e7644ded2b..382a6c5ef43 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -450,6 +450,11 @@ GEM actionmailer (>= 3) premailer (~> 1.7, >= 1.7.9) profanity_filter (0.1.1) + propshaft (0.7.0) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + railties (>= 7.0.0) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) @@ -634,13 +639,6 @@ GEM simpleidn (0.2.1) unf (~> 0.1.4) smart_properties (1.17.0) - sprockets (4.0.2) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) stringex (2.8.5) strong_migrations (0.8.0) activerecord (>= 5.2) @@ -765,6 +763,7 @@ DEPENDENCIES jwt knapsack letter_opener (~> 1.8) + listen lograge (>= 0.11.2) lookbook (~> 1.5.3) lru_redux @@ -780,6 +779,7 @@ DEPENDENCIES phonelib premailer-rails (>= 1.11.1) profanity_filter + propshaft pry-byebug pry-doc pry-rails @@ -818,7 +818,6 @@ DEPENDENCIES simplecov (~> 0.21.0) simplecov-cobertura simplecov_json_formatter - sprockets-rails stringex strong_migrations (>= 0.4.2) subprocess diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js deleted file mode 100644 index 6b147d7d533..00000000000 --- a/app/assets/config/manifest.js +++ /dev/null @@ -1,10 +0,0 @@ -//= link_tree ../images -//= link_tree ../fonts - -//= link intl-tel-input/build/css/intlTelInput.css -//= link intl-tel-input/build/img/flags.png -//= link intl-tel-input/build/img/flags@2x.png - -//= link_tree ../../../node_modules/@18f/identity-design-system/dist/assets/img -//= link_tree ../../../node_modules/@18f/identity-design-system/dist/assets/fonts -//= link_tree ../builds diff --git a/app/assets/stylesheets/_required.scss b/app/assets/stylesheets/_required.scss index 248473430ec..4943301560a 100644 --- a/app/assets/stylesheets/_required.scss +++ b/app/assets/stylesheets/_required.scss @@ -1,7 +1,7 @@ @use 'uswds-core' with ( $theme-body-font-size: 'sm', $theme-font-path: '.', - $theme-image-path: '@18f/identity-design-system/dist/assets/img', + $theme-image-path: '.', $theme-global-border-box-sizing: true, $theme-global-link-styles: true, $theme-grid-container-max-width: 'tablet-lg', diff --git a/app/assets/stylesheets/components/_language-picker.scss b/app/assets/stylesheets/components/_language-picker.scss index e6d14f6823b..0e56b95d957 100644 --- a/app/assets/stylesheets/components/_language-picker.scss +++ b/app/assets/stylesheets/components/_language-picker.scss @@ -66,10 +66,10 @@ } &::after { - background-image: url(@18f/identity-design-system/dist/assets/img/angle-arrow-up.svg); + background-image: url(angle-arrow-up.svg); @include at-media('tablet') { - background-image: url(@18f/identity-design-system/dist/assets/img/angle-arrow-up-white.svg); + background-image: url(angle-arrow-up-white.svg); } } } @@ -79,7 +79,7 @@ color: color('white'); &::after { - background-image: url(@18f/identity-design-system/dist/assets/img/angle-arrow-down-white.svg); + background-image: url(angle-arrow-down-white.svg); } } } diff --git a/app/assets/stylesheets/components/_phone-input.scss b/app/assets/stylesheets/components/_phone-input.scss index 07f0e973b95..3f6ae7042e4 100644 --- a/app/assets/stylesheets/components/_phone-input.scss +++ b/app/assets/stylesheets/components/_phone-input.scss @@ -8,11 +8,11 @@ lg-phone-input { } .iti__flag { - background-image: url('intl-tel-input/build/img/flags.png'); + background-image: url('flags.png'); /* stylelint-disable-next-line media-feature-name-no-vendor-prefix */ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { - background-image: url('intl-tel-input/build/img/flags@2x.png'); + background-image: url('flags@2x.png'); } } diff --git a/app/components/icon_component.rb b/app/components/icon_component.rb index 7976d647003..f0c679a5955 100644 --- a/app/components/icon_component.rb +++ b/app/components/icon_component.rb @@ -1,6 +1,4 @@ class IconComponent < BaseComponent - include AssetHelper - # See: https://github.com/uswds/uswds/tree/develop/src/img/usa-icons ICONS = %i[ accessibility_new @@ -256,7 +254,7 @@ def initialize(icon:, **tag_options) end def icon_path - asset_path([design_system_asset_path('img/sprite.svg'), '#', icon].join, host: asset_host) + asset_path([asset_path('sprite.svg'), '#', icon].join, host: asset_host) end private diff --git a/app/components/phone_input_component.html.erb b/app/components/phone_input_component.html.erb index 24a495525de..a6d5ce7ecf9 100644 --- a/app/components/phone_input_component.html.erb +++ b/app/components/phone_input_component.html.erb @@ -53,4 +53,4 @@ }, ) %> <% end %> -<%= stylesheet_link_tag 'intl-tel-input/build/css/intlTelInput' %> +<%= stylesheet_link_tag 'intlTelInput' %> diff --git a/app/decorators/service_provider_session_decorator.rb b/app/decorators/service_provider_session_decorator.rb index 83ad7cce508..9bd38fb5fc4 100644 --- a/app/decorators/service_provider_session_decorator.rb +++ b/app/decorators/service_provider_session_decorator.rb @@ -42,6 +42,8 @@ def s3_logo_url(service_provider) def legacy_logo_url logo = sp_logo ActionController::Base.helpers.image_path("sp-logos/#{logo}") + rescue Propshaft::MissingAssetError + nil end def new_session_heading diff --git a/app/helpers/asset_helper.rb b/app/helpers/asset_helper.rb deleted file mode 100644 index 4a4d013ca9c..00000000000 --- a/app/helpers/asset_helper.rb +++ /dev/null @@ -1,7 +0,0 @@ -module AssetHelper - DESIGN_SYSTEM_ASSET_ROOT = '@18f/identity-design-system/dist/assets'.freeze - - def design_system_asset_path(path) - File.join(DESIGN_SYSTEM_ASSET_ROOT, path) - end -end diff --git a/app/helpers/script_helper.rb b/app/helpers/script_helper.rb index 1f7ba137b16..b2da5680250 100644 --- a/app/helpers/script_helper.rb +++ b/app/helpers/script_helper.rb @@ -39,7 +39,7 @@ def render_javascript_pack_once_tags(*names) private SAME_ORIGIN_ASSETS = %w[ - @18f/identity-design-system/dist/assets/img/sprite.svg + sprite.svg ].to_set.freeze def local_crossorigin_sources? diff --git a/app/javascript/packages/components/icon.tsx b/app/javascript/packages/components/icon.tsx index 5bd6d85083c..a0b57b7e74e 100644 --- a/app/javascript/packages/components/icon.tsx +++ b/app/javascript/packages/components/icon.tsx @@ -1,6 +1,6 @@ import { getAssetPath } from '@18f/identity-assets'; -const SPRITE_URL = getAssetPath('@18f/identity-design-system/dist/assets/img/sprite.svg'); +const SPRITE_URL = getAssetPath('sprite.svg'); export type DesignSystemIcon = | 'accessibility_new' diff --git a/app/views/accounts/_unphishable_badge.html.erb b/app/views/accounts/_unphishable_badge.html.erb index ff2873288ba..d93bdfe0130 100644 --- a/app/views/accounts/_unphishable_badge.html.erb +++ b/app/views/accounts/_unphishable_badge.html.erb @@ -1,6 +1,6 @@
<%= image_tag( - design_system_asset_path('img/alerts/unphishable.svg'), + asset_path('alerts/unphishable.svg'), size: 16, class: 'text-middle', alt: '', diff --git a/app/views/accounts/_verified_account_badge.html.erb b/app/views/accounts/_verified_account_badge.html.erb index f43f4f70768..7a4df1b1628 100644 --- a/app/views/accounts/_verified_account_badge.html.erb +++ b/app/views/accounts/_verified_account_badge.html.erb @@ -1,6 +1,6 @@
<%= image_tag( - design_system_asset_path('img/alerts/success.svg'), + asset_path('alerts/success.svg'), size: 16, class: 'text-middle', alt: '', diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index ca6388bd659..302e2562f11 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -29,25 +29,25 @@ <%= csrf_meta_tags %> <%= favicon_link_tag( - design_system_asset_path('img/favicons/apple-touch-icon.png'), + asset_path('favicons/apple-touch-icon.png'), rel: 'apple-touch-icon', sizes: '180x180', type: 'image/png', ) %> <%= favicon_link_tag( - design_system_asset_path('img/favicons/favicon-40.png'), + asset_path('favicons/favicon-40.png'), rel: 'icon', sizes: '40x40', type: 'image/png', ) %> <%= favicon_link_tag( - design_system_asset_path('img/favicons/favicon-16.png'), + asset_path('favicons/favicon-16.png'), rel: 'icon', sizes: '16x16', type: 'image/png', ) %> <%= favicon_link_tag( - design_system_asset_path('img/favicons/safari-pinned-tab.svg'), + asset_path('favicons/safari-pinned-tab.svg'), rel: 'mask-icon', color: '#e21c3d', type: nil, diff --git a/app/views/shared/_banner-lock-icon.html.erb b/app/views/shared/_banner-lock-icon.html.erb index feef6e8ee5a..e4da7888a37 100644 --- a/app/views/shared/_banner-lock-icon.html.erb +++ b/app/views/shared/_banner-lock-icon.html.erb @@ -1,5 +1,5 @@ <%= image_tag( - design_system_asset_path('img/lock.svg'), + asset_path('lock.svg'), width: 9, height: 12, class: 'usa-banner__lock-image', diff --git a/config/application.rb b/config/application.rb index cb186ffee26..c788559fec9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -5,7 +5,6 @@ require 'action_view/railtie' require 'action_mailer/railtie' require 'rails/test_unit/railtie' -require 'sprockets/railtie' require 'identity/logging/railtie' require_relative '../lib/asset_sources' @@ -56,8 +55,6 @@ class Application < Rails::Application config.load_defaults '7.0' config.active_record.belongs_to_required_by_default = false config.active_record.legacy_connection_handling = false - config.assets.unknown_asset_fallback = true - config.assets.resolve_assets_in_css_urls = true config.active_job.queue_adapter = :good_job FileUtils.mkdir_p(Rails.root.join('log')) diff --git a/config/environments/development.rb b/config/environments/development.rb index 1306d3da830..928cceb38fc 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -4,10 +4,7 @@ config.consider_all_requests_local = true config.active_support.deprecation = :log config.active_record.migration_error = :page_load - config.assets.debug = true - config.assets.digest = true - config.assets.gzip = false - config.assets.raise_runtime_errors = true + config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.i18n.raise_on_missing_translations = true # Raise exceptions for disallowed deprecations. diff --git a/config/environments/production.rb b/config/environments/production.rb index 330ac83cb27..4935e502264 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -6,14 +6,7 @@ config.action_controller.perform_caching = true config.force_ssl = true - config.asset_host = proc do |_source, request| - # we want precompiled assets to have domain-agnostic URLs - # and request is nil during asset precompilation - (IdentityConfig.store.asset_host.presence || IdentityConfig.store.domain_name) if request - end - config.assets.compile = false - config.assets.digest = true - config.assets.gzip = false + config.asset_host = IdentityConfig.store.asset_host.presence || IdentityConfig.store.domain_name config.i18n.fallbacks = true config.active_support.deprecation = :notify config.active_record.dump_schema_after_migration = false diff --git a/config/environments/test.rb b/config/environments/test.rb index 7a3bb2b6afa..cc6088fca3c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,15 +12,12 @@ config.action_controller.allow_forgery_protection = false config.active_support.test_order = :random config.active_support.deprecation = :stderr - config.assets.gzip = false config.i18n.raise_on_missing_translations = true config.action_mailer.delivery_method = :test config.action_mailer.default_url_options = { host: IdentityConfig.store.domain_name } config.action_mailer.asset_host = IdentityConfig.store.mailer_domain_name - config.assets.debug = false - # Raise exceptions for disallowed deprecations. config.active_support.disallowed_deprecation = :raise @@ -32,8 +29,6 @@ config.action_controller.asset_host = ENV['RAILS_ASSET_HOST'] if ENV.key?('RAILS_ASSET_HOST') - config.assets.digest = ENV.key?('RAILS_DISABLE_ASSET_DIGEST') ? false : true - config.middleware.use RackSessionAccess::Middleware config.after_initialize do diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index cc0cc161230..9d43c2aae76 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -5,13 +5,8 @@ # Add additional assets to the asset load path Rails.application.config.assets.paths.push( - 'node_modules', + 'node_modules/intl-tel-input/build/img', + 'node_modules/intl-tel-input/build/css', + 'node_modules/@18f/identity-design-system/dist/assets/img', 'node_modules/@18f/identity-design-system/dist/assets/fonts', ) - -# Fix sassc sometimes segfaulting -Rails.application.config.assets.configure do |env| - env.export_concurrent = false -end - -Sprockets.export_concurrent = Rails.env.test? diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index b40fcaab89f..0867ca17ede 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -85,14 +85,6 @@ Use Control+X to save the file. Restart your Mac to cause the .plist to take effect. Check the limits again and you should see both `ulimit -n` and `launchctl limit maxfiles` return a limit of 524288. -### Errors related to _sassc_ - -If you are getting the error: -``` -LoadError: cannot load such file -- sassc -``` -Try `make run` for a short time, then use Ctrl+C to kill it - ### Errors relating to OpenSSL versions If you get this error during test runs: diff --git a/scripts/artifact-upload b/scripts/artifact-upload index 10b4c467914..99eae75e51a 100755 --- a/scripts/artifact-upload +++ b/scripts/artifact-upload @@ -33,7 +33,7 @@ branch_environments.map do |upload_environment| raise 'artifact copy failed' unless status.success? assets_sync_command = <<-CMD - aws s3 sync --size-only --cache-control max-age=31536000 --exclude .sprockets-manifest-*.json public/assets s3://#{static_bucket}/assets + aws s3 sync --size-only --cache-control max-age=31536000 --exclude ".manifest.json" public/assets s3://#{static_bucket}/assets CMD _output, status = Open3.capture2(assets_sync_command) raise 'assets sync failed' unless status.success? diff --git a/spec/helpers/asset_helper_spec.rb b/spec/helpers/asset_helper_spec.rb deleted file mode 100644 index 3952a2b34f2..00000000000 --- a/spec/helpers/asset_helper_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -RSpec.describe AssetHelper do - include AssetHelper - - describe 'design_system_asset_path' do - let(:path) { 'img/example.png' } - - subject(:asset_path) { design_system_asset_path(path) } - - it 'produces an asset path' do - expect(asset_path).to eq('@18f/identity-design-system/dist/assets/img/example.png') - end - - context 'with leading slash' do - let(:path) { '/img/example.png' } - - it 'produces an asset path' do - expect(asset_path).to eq('@18f/identity-design-system/dist/assets/img/example.png') - end - end - end -end diff --git a/spec/helpers/script_helper_spec.rb b/spec/helpers/script_helper_spec.rb index f0abd0d6489..5e82355dd38 100644 --- a/spec/helpers/script_helper_spec.rb +++ b/spec/helpers/script_helper_spec.rb @@ -32,7 +32,7 @@ allow(AssetSources).to receive(:get_sources).with('application', 'document-capture'). and_return(['/application.js', '/document-capture.js']) allow(AssetSources).to receive(:get_assets).with('application', 'document-capture'). - and_return(['clock.svg', '@18f/identity-design-system/dist/assets/img/sprite.svg']) + and_return(['clock.svg', 'sprite.svg']) end it 'prints asset paths sources' do @@ -43,8 +43,7 @@ visible: :all, text: { 'clock.svg' => 'http://test.host/clock.svg', - '@18f/identity-design-system/dist/assets/img/sprite.svg' => - 'http://test.host/@18f/identity-design-system/dist/assets/img/sprite.svg', + 'sprite.svg' => 'http://test.host/sprite.svg', }.to_json, ) end @@ -66,8 +65,7 @@ visible: :all, text: { 'clock.svg' => 'http://assets.example.com/clock.svg', - '@18f/identity-design-system/dist/assets/img/sprite.svg' => - 'http://example.com/@18f/identity-design-system/dist/assets/img/sprite.svg', + 'sprite.svg' => 'http://example.com/sprite.svg', }.to_json, ) end diff --git a/spec/requests/rack_attack_spec.rb b/spec/requests/rack_attack_spec.rb index 3bf0ddf219b..e91280f2d1c 100644 --- a/spec/requests/rack_attack_spec.rb +++ b/spec/requests/rack_attack_spec.rb @@ -38,9 +38,18 @@ end context 'when the request is for an asset' do + let(:asset_url) { '/assets/application.css' } + let(:asset_path) { Rails.root.join('public', asset_url.sub(/^\//, '')) } + + before do + asset_dirname = File.dirname(asset_path) + FileUtils.mkdir_p(asset_dirname) unless File.directory?(asset_dirname) + File.write(asset_path, '') unless File.exist?(asset_path) + end + it 'does not throttle' do (requests_per_ip_limit + 1).times do - get '/assets/application.css', headers: { REMOTE_ADDR: '1.2.3.4' } + get asset_url, headers: { REMOTE_ADDR: '1.2.3.4' } end expect(response.status).to eq(200) @@ -48,8 +57,16 @@ end context 'when the request is for a pack' do + let(:pack_url) { '/packs/js/application.js' } + let(:pack_path) { Rails.root.join('public', pack_url.sub(/^\//, '')) } + + before do + pack_dirname = File.dirname(pack_path) + FileUtils.mkdir_p(pack_dirname) unless File.directory?(pack_dirname) + File.write(pack_path, '') unless File.exist?(pack_path) + end + it 'does not throttle' do - pack_url = Dir['public/packs/js/*'].first.gsub(/^public/, '') (requests_per_ip_limit + 1).times do get pack_url, headers: { REMOTE_ADDR: '1.2.3.4' } end diff --git a/webpack.config.js b/webpack.config.js index 63ff55a4c95..adaf513734c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,7 +12,7 @@ const isLocalhost = host === 'localhost'; const isProductionEnv = env === 'production'; const isTestEnv = env === 'test'; const mode = isProductionEnv ? 'production' : 'development'; -const hashSuffix = isProductionEnv ? '-[chunkhash:8]' : ''; +const hashSuffix = isProductionEnv ? '-[chunkhash:8].digested' : ''; const devServerPort = process.env.WEBPACK_PORT; const devtool = process.env.WEBPACK_DEVTOOL || (isProductionEnv ? 'source-map' : 'eval-source-map');