# 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
