Skip to content

Instantly share code, notes, and snippets.

@ThatGuySam
Created November 1, 2018 20:33
Show Gist options
  • Save ThatGuySam/ee70208c158e1a09171642b7949734f2 to your computer and use it in GitHub Desktop.
Save ThatGuySam/ee70208c158e1a09171642b7949734f2 to your computer and use it in GitHub Desktop.
Switches between dev and production resources - Designed to work with Laravel Mix + Valet + Zeit's Now
var sectionId = '';
var isDev;
var assetDomain = 'https://production.now.sh';
if(window.localStorage) {
isDev = localStorage.getItem("isDev");
}
if (isDev) {
console.log('Using local assets');
assetDomain = 'https://development.test';
}
var externalScript = document.createElement('script');
externalScript.setAttribute('src', assetDomain + '/public/js/app.js');
document.head.appendChild(externalScript);
var externalStyle = document.createElement("link");
externalStyle.setAttribute("rel", "stylesheet");
externalStyle.setAttribute("type", "text/css");
externalStyle.setAttribute("href", assetDomain + '/public/css/app.css');
document.head.appendChild(externalStyle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment