Skip to content

Commit 85f9b3b

Browse files
committed
fix(dev): Register static assets without identifier for relative src paths
The staticAssetsMapper was only registering paths with the config key name (e.g., 'assets'), which broke relative asset references like src='./cat.png'. Changes: 1. Dev server: Register assets at both target/identifier/file and target/file so relative paths like src='./cat.png' resolve correctly 2. Deploy: Add destination: 'assets' to include_assets step so assets are copied to assets/ subdirectory with correct manifest paths Fixes #5285
1 parent 3a92d03 commit 85f9b3b

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

packages/app/src/cli/models/extensions/specifications/ui_extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const uiExtensionSpec = createExtensionSpecification({
113113
anchor: 'extension_points[]',
114114
groupBy: 'target',
115115
key: 'extension_points[].assets',
116+
destination: 'assets',
116117
},
117118
{
118119
type: 'configKey',

packages/app/src/cli/services/dev/extension/payload.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ describe('getUIExtensionPayload', () => {
420420
])
421421
expect(resolver.get('CUSTOM_EXTENSION_POINT/assets/foo.json')).toBe('foo.json')
422422
expect(resolver.get('CUSTOM_EXTENSION_POINT/assets/subdir/bar.png')).toBe('subdir/bar.png')
423+
expect(resolver.get('CUSTOM_EXTENSION_POINT/foo.json')).toBe('foo.json')
424+
expect(resolver.get('CUSTOM_EXTENSION_POINT/subdir/bar.png')).toBe('subdir/bar.png')
423425
})
424426
})
425427

@@ -475,6 +477,8 @@ describe('getUIExtensionPayload', () => {
475477
// Both targets' resolver entries point at the same output-relative file.
476478
expect(resolver.get('TARGET_A/assets/foo.json')).toBe('foo.json')
477479
expect(resolver.get('TARGET_B/assets/foo.json')).toBe('foo.json')
480+
expect(resolver.get('TARGET_A/foo.json')).toBe('foo.json')
481+
expect(resolver.get('TARGET_B/foo.json')).toBe('foo.json')
478482
})
479483
})
480484

packages/app/src/cli/services/dev/extension/payload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ async function staticAssetsMapper(
253253
const urlSubpath = `${target}/${identifier}`
254254
for (const file of files) {
255255
resolver?.set(`${urlSubpath}/${file}`, file)
256+
resolver?.set(`${target}/${file}`, file)
256257
}
257258
const updatedTimestamps = await Promise.all(
258259
files.map(async (file) => (await fileLastUpdatedTimestamp(joinPath(buildDirectory, file))) ?? 0),

0 commit comments

Comments
 (0)