repack icon indicating copy to clipboard operation
repack copied to clipboard

add assetPath to remote assets config

Open adammruk opened this issue 1 year ago • 4 comments

Closes #625

Summary

This pull request adds a new field to the remote assets configuration, allowing the specification of both the path and filename for an asset. Will be reflected in generated URL in AssetSourceResolver

Test plan

  1. (optional) Ensure that minification in webpack.config is disabled to make the generated JS code easier to inspect.
  2. Add the following option to the remote-assets section of your webpack.config.js file:
                assetPath: ({
                  resourcePath,
                  resourceFilename,
                  resourceDirname,
                  resourceExtensionType 
                }) => {
                  const randomHex = Math.random().toString(16).slice(2, 8)
                  return `${resourceDirname}/one-more-folder/${resourceFilename}-${randomHex}.${resourceExtensionType}`
                },
  1. Build bundle
  2. Verify that the remote assets are located in the specified folder and that the filenames include a random hash.
  3. Check that the generated JavaScript chunk contains a valid URL passed to AssetSourceResolver.

adammruk avatar Jun 20 '24 06:06 adammruk