discourse/lib/freedom_patches
David Taylor e7450cc6da
DEV: Migrate from sprockets to propshaft for assets (#32475)
We are no longer using any of the transpilation/bundling features of
Sprockets. We only use it to serve assets in development, and then
collect & fingerprint them in production. This commit switches us to use
the more modern "Propshaft" gem for that functionality.

Propshaft is much simpler than Sprockets. Instead of taking a
combination of paths + "precompile" list, Propshaft simply assumes all
files in the configured directory are required in production. Previously
we had some base paths configured quite high in the directory structure,
and then only precompiled selected assets within the directory. That's
no longer possible, so this commit refactors those places (mostly
plugin-related) to use dedicated directories under
`app/assets/generated/`.

Another difference is that Propshaft applies asset digests in
development as well as production. This is great for caching & dev/prod
consistency, but does mean some small changes were required in tests.

We previously had some freedom-patches applied to Sprockets. Some of
those had to be ported across to Propshaft. We now have three patches:

1. Skip adding digest hashes to webpack-generated chunks (which are
already digested, and referred to from other js files)

2. Avoid raising errors for missing assets in test mode. We don't always
compile assets before running basic RSpec tests.

3. Maintain relative paths for sourcemap URLs, so that files don't need
to be recompiled depending on their CDN path

Significant refactors are made to the `assets.rake` and `s3.rake` tasks,
which rely on implementation details of Sprockets/Propshaft.
2025-04-30 08:59:32 +01:00
..
active_record_attribute_methods.rb DEV: Clean up freedom patches 2022-04-06 10:07:14 +02:00
active_record_disable_serialization.rb DEV: Remove unnecessary freedom patches 2024-08-19 12:06:54 +02:00
ams_include_without_root.rb
copy_file.rb DEV: Work around a Docker issue (#13368) 2021-06-14 17:38:36 +02:00
cose_rsapkcs1.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
fast_image.rb SECURITY: Add FastImage SSRF safe freedom patch 2024-07-03 20:49:15 +08:00
fast_pluck.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
inflector_backport.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
ip_addr.rb DEV: Fix various rubocop lints (#24749) 2023-12-06 23:25:00 +01:00
net_http.rb FIX: Set sane default for Net::HTTP when processing a request (#28141) 2024-08-06 07:12:42 +08:00
net_http_header.rb DEV: Add a user agent to all HTTP requests that Discourse makes. (#31555) 2025-03-03 16:32:25 +11:00
propshaft_patches.rb DEV: Migrate from sprockets to propshaft for assets (#32475) 2025-04-30 08:59:32 +01:00
rails_multisite.rb PERF: Don't do initialization for every DB if RAILS_DB is set (#28668) 2024-09-03 15:56:46 +10:00
safe_buffer.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
safe_migrations.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
schema_migration_details.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
sidekiq.rb DEV: Upgrade Sidekiq to v7.3.9 2025-03-10 15:02:48 +01:00
translate_accelerator.rb DEV: Remove unnecessary freedom patches 2024-08-19 12:06:54 +02:00
web_push_request.rb SECURITY: Monkey-patch web-push gem to use safer HTTP client 2023-03-16 15:27:09 -06:00