@@ -5,8 +5,8 @@ import {loadLocalesConfig} from '../../../utilities/extensions/locales-configura
55import { getExtensionPointTargetSurface } from '../../../services/dev/extension/utilities.js'
66import { ExtensionInstance } from '../extension-instance.js'
77import { err , ok , Result } from '@shopify/cli-kit/node/result'
8- import { fileExists } from '@shopify/cli-kit/node/fs'
9- import { joinPath } from '@shopify/cli-kit/node/path'
8+ import { copyFile , fileExists } from '@shopify/cli-kit/node/fs'
9+ import { joinPath , basename , dirname } from '@shopify/cli-kit/node/path'
1010import { outputContent , outputToken } from '@shopify/cli-kit/node/output'
1111import { zod } from '@shopify/cli-kit/node/schema'
1212
@@ -27,6 +27,7 @@ export interface BuildManifest {
2727 [ key in AssetIdentifier ] ?: {
2828 filepath : string
2929 module ?: string
30+ static ?: boolean
3031 }
3132 }
3233}
@@ -57,6 +58,15 @@ export const UIExtensionSchema = BaseSchema.extend({
5758 } ,
5859 }
5960 : null ) ,
61+ ...( targeting . tools
62+ ? {
63+ [ AssetIdentifier . Tools ] : {
64+ filepath : `${ config . handle } -${ AssetIdentifier . Tools } -${ basename ( targeting . tools ) } ` ,
65+ module : targeting . tools ,
66+ static : true ,
67+ } ,
68+ }
69+ : null ) ,
6070 } ,
6171 }
6272
@@ -125,6 +135,11 @@ const uiExtensionSpec = createExtensionSpecification({
125135 return
126136 }
127137
138+ // Skip static assets - they are copied after esbuild completes in rebuildContext
139+ if ( asset . static && asset . module ) {
140+ return
141+ }
142+
128143 assets [ identifier ] = {
129144 identifier : identifier as AssetIdentifier ,
130145 outputFileName : asset . filepath ,
@@ -143,6 +158,26 @@ const uiExtensionSpec = createExtensionSpecification({
143158 ...( assetsArray . length ? { assets : assetsArray } : { } ) ,
144159 }
145160 } ,
161+ copyStaticAssets : async ( config , directory , outputPath ) => {
162+ if ( ! isRemoteDomExtension ( config ) ) return
163+
164+ await Promise . all (
165+ config . extension_points . map ( ( extensionPoint ) => {
166+ if ( ! ( 'build_manifest' in extensionPoint ) ) return Promise . resolve ( )
167+
168+ return Object . entries ( extensionPoint . build_manifest . assets ) . map ( ( [ _ , asset ] ) => {
169+ if ( asset . static && asset . module ) {
170+ const sourceFile = joinPath ( directory , asset . module )
171+ const outputFilePath = joinPath ( dirname ( outputPath ) , asset . filepath )
172+ return copyFile ( sourceFile , outputFilePath ) . catch ( ( error ) => {
173+ throw new Error ( `Failed to copy static asset ${ asset . module } to ${ outputFilePath } : ${ error . message } ` )
174+ } )
175+ }
176+ return Promise . resolve ( )
177+ } )
178+ } ) ,
179+ )
180+ } ,
146181 hasExtensionPointTarget : ( config , requestedTarget ) => {
147182 return (
148183 config . extension_points ?. find ( ( extensionPoint ) => {
0 commit comments