Can you override a library per environment?
Look at hook_page_attachments. In the sample snippet provided behind that link there is a simple if-request which attaches a certain library only when a certain condition is met. Do the same.

MYTHEME/MYMODULE.libraries.yml

foo-bar-dev:
  version: 0.0.x
  js:
    js/foo-dev.js: {}
foo-bar-prod:
  version: 0.0.x
  js:
    js/foo-prod.js: {}


MYTHEME.theme/MYMODULE.module

function MYTHEME/MYMODULE_page_attachments(array &amp;$attachments) {

  // Conditionally attach an asset to the page.
  if (\Drupal::request()-&gt;getHost() == 'example.com') {
    $attachments['#attached']['library'][] = 'MYTHEME/MYMODULE/foo-bar-prod';
  }
  else {
    $attachments['#attached']['library'][] = 'MYTHEME/MYMODULE/foo-bar-dev';
  }
}




More info on base URL: how to get base url of a site?.