M3 Docs - Discussion of setBundledJsCssUrlRewriteHook?

The the M2 docs had a discussion of how to set up an app to run on Cloudfront:

To get Meteor to use the CDN for your Javascript and CSS bundles, call WebAppInternals.setBundledJsCssPrefix("http://mycdn.com") on the server. This will also take care of relative image URLs inside your CSS files. If you need to use a dynamic prefix, you can return the prefix from a function passed to WebAppInternals.setBundledJsCssUrlRewriteHook()

I haven’t yet found documention for this, or for the related WebAppInternals.setBundledJsCssUrlRewriteHook() function, in the M3 docs, other than a reference here that it is now an async function.

For example, is this code correct in M3?

if (Meteor.isProduction) {
    await WebAppInternals.setBundledJsCssUrlRewriteHook(
        url => `https://d2kwqyvya3b342.cloudfront.net${url}&_g_app_v_=${process.env.GALAXY_APP_VERSION_ID}`
    );
}

I guess it should work both ways but I use it with no await.

Although the function might seem async, there is nothing async inside it (which is not already awaited).
I believe the type of the function is also not async: meteor/packages/webapp/webapp.d.ts at fa45160d9cab879dd370ffe91b24fa2491d4e10b · meteor/meteor · GitHub

1 Like

Thanks, @paulishca . I used this variation last night and it worked great.