0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 02:11:32 +08:00
discourse/config/initializers/assets.rb
David Taylor 9527868295
DEV: Replace JS build system with Rolldown (#35963)
This replaces the old ember-cli build with a modern Rolldown build. In
local testing, this provides an 80% improvement in build times, while
remaining 100% backwards compatible for themes and plugins.

As part of this move, we have decided to stop using a proxy in front of
Discourse for development. Development should now be done directly
against the Rails server.

`bin/ember-cli -u` has been replaced with `bin/dev`. This will launch
Rails on `:3000`, and will run the rolldown build in the background. Log
output from both processes will be shown with an appropriate prefix. You
should visit `:3000` in your browser. `:4200` will no longer serve
anything.

To help with migration, `bin/ember-cli` is now a backwards-compatible
shim. It will print help information, and will launch a lightweight
server on `:4200` with instructions to move to `:3000`.

If you prefer to launch Rails and the JS build as separate commands, you
can still do that. Rails boot commands are unchanged, and the rolldown
development builder can be run using `bin/dev --only ember`.

https://meta.discourse.org/t/403908

---------

Co-authored-by: Jarek Radosz <jarek@cvx.dev>
Co-authored-by: Chris Manson <chris@manson.ie>
2026-05-29 11:11:55 +01:00

35 lines
1.3 KiB
Ruby
Vendored

# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Enable the asset pipeline
Rails.application.config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "2-#{GlobalSetting.asset_url_salt}"
# Add additional assets to the asset load path.
Rails.application.config.assets.paths.push(
"#{Rails.public_path.join("javascripts")}",
"#{Rails.root.join("frontend/discourse/dist/assets")}",
"#{Rails.root.join("frontend/discourse/dist/@embroider/virtual")}",
"#{Rails.root.join("frontend/discourse/scripts")}",
)
Rails.application.config.assets.paths.push(
*Discourse.plugins.map { |p| "#{Rails.root.join("app/assets/generated/#{p.directory_name}/")}" },
)
# These paths are added automatically by propshaft, but we don't want them
Rails.application.config.assets.excluded_paths.push(
"#{Rails.root.join("app/assets/generated")}",
"#{Rails.root.join("app/assets/javascripts")}",
"#{Rails.root.join("app/assets/stylesheets")}",
)
# We don't need/want most of Propshaft's preprocessing. Only keep the JS sourcemap handler
Rails.application.config.assets.compilers.filter! do |type, compiler|
type == "text/javascript" && compiler == Propshaft::Compiler::SourceMappingUrls
end
Mime::Type.register "application/wasm", :wasm