Is there a way to change the static path Meteor serves of the initial js and css?

I want to build a plugin that on build time uploads the static content to S3/Cloudfront and I don’t want to use a proxy to point to a CDN. I want to change the script tag url path.
I tried ROOT_URL_PATH_PREFIX but it didn’t work :confused:

Is that any possible or I will need to make a script after bundling to change it?

meteor add meteorhacks:inject-initial


//anywhere in server code

Inject.rawModHtml('changeScriptSrc', function(html) { //you're required to name the call, it can be anything
    return html.replace(
         /<script type="text\/javascript" src="/g, 
        '<script type="text/javascript" src="http://s3.myfiles.com'
    );
});
1 Like