Here's an example: https://gist.run?id=08ea8ae278f4022d012753c2533097bf
config.js
const isDev = /^http:\/\/localhost/.test(location.origin);
export const workerOrigin = isDev ? 'http://localhost:3000' : req.host.;
export const workerPage = workerOrigin + '/';
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script data-require="[email protected]" data-semver="0.12.0" src="https://raw.githubusercontent.com/aurelia/http-client/master/dist/aurelia-http-client.js"></script>
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Hello world!</h1>
<script src="main.js"></script>
</body>
</html>
main.js
import {activate as activateWorker} from './worker/worker-activator';
export function configure(aurelia) {
aurelia.use.standardConfiguration();
aurelia.start()
.then(() => {
if ('serviceWorker' in navigator) {
let root = /\/embed/.test(location.href) ? 'ui/embed/app' : 'ui/app';
return aurelia.setRoot(root).then(activateWorker);
}
return aurelia.setRoot('ui/fallback');
});
}