Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix assets manifest building for sourcemaps

Alexander Brandon Coles3170b438df24
diff --git a/frontend/esbuild/plugins.ts b/frontend/esbuild/plugins.ts
index 9a33e05d42a..282c8959d0c 100644
--- a/frontend/esbuild/plugins.ts
+++ b/frontend/esbuild/plugins.ts
@@ -32,7 +32,7 @@ import type { Plugin } from 'esbuild';
const customConfigPlugin:Plugin = {
name: 'custom-config',
- setup({ initialOptions:options }) {
+ setup({ initialOptions: options }) {
if (options.chunkNames === '[name]-[hash]') { // named chunks
options.chunkNames = '[dir]/[name]-[hash]';
}
diff --git a/lib/open_project/assets.rb b/lib/open_project/assets.rb
index ab717f9db1c..c5d70a14d17 100644
--- a/lib/open_project/assets.rb
+++ b/lib/open_project/assets.rb
@@ -73,12 +73,12 @@ module OpenProject
# Create map of asset chunk name to current hash
manifest = current_assets.filter_map do |asset|
- name = asset.basename(asset.extname).to_s
+ name, extname = split_basename(asset)
case name.match(/\A(?<unhashed_name>[^.]+)[-\.][A-Z0-9]{8}\z/)
in unhashed_name: "chunk"
[asset, asset]
in unhashed_name:
- [asset.parent.join(unhashed_name + asset.extname), asset]
+ [asset.parent.join(unhashed_name + extname), asset]
else
nil # Non-hashed asset: no-op
end
@@ -93,6 +93,19 @@ module OpenProject
.select(&:file?)
.map { it.relative_path_from(frontend_asset_path) }
end
+
+ def split_basename(pathname)
+ ext1 = pathname.extname
+ base = pathname.basename(ext1)
+
+ if ext1 == ".map"
+ ext2 = base.extname
+ base = base.basename(ext2)
+ [base.to_s, ext2 + ext1]
+ else
+ [base.to_s, ext1]
+ end
+ end
end
end
end