Commit a3dc82e3 authored by Robert Knight's avatar Robert Knight

Bake the local asset server's URL into the boot script

When building the client in development mode, make the client load
assets from the package content server by default.

Also if `H_SERVICE_URL` is set, bake that service's /app.html endpoint
into the boot script.
parent 6dcec091
......@@ -248,8 +248,17 @@ function triggerLiveReload(changedFiles) {
* @param {Object} manifest - Manifest mapping asset paths to cache-busted URLs
*/
function generateBootScript(manifest) {
var { version } = require('./package.json');
var defaultAssetRoot = process.env.NODE_ENV === 'production' ?
`https://cdn.hypothes.is/hypothesis/${version}/` : `http://localhost:3001/hypothesis@${version}/`;
var defaultSidebarAppUrl = process.env.H_SERVICE_URL ?
`${process.env.H_SERVICE_URL}/app.html` : 'https://hypothes.is/app.html';
gulp.src('build/scripts/boot.bundle.js')
.pipe(replace('__MANIFEST__', JSON.stringify(manifest)))
.pipe(replace('__ASSET_ROOT__', defaultAssetRoot))
.pipe(replace('__SIDEBAR_APP_URL__', defaultSidebarAppUrl))
.pipe(rename('boot.js'))
.pipe(gulp.dest('build/'));
}
......
......@@ -7,19 +7,15 @@
// already has it cached when it encounters the reference in the sidebar
// application.
// Variables replaced by the build script
/* global __MANIFEST__ */
var boot = require('./boot');
var settings = require('../shared/settings')(document);
// The `sidebarAppUrl` and `assetRoot` settings are set by the service which is
// serving the Hypothesis client to tell it where to load the sidebar and assets
// from.
var defaultAssetRoot = 'https://cdn.hypothes.is/hypothesis/__VERSION__/';
boot(document, {
assetRoot: settings.assetRoot || defaultAssetRoot,
manifest: __MANIFEST__, // Replaced by build script
sidebarAppUrl: settings.sidebarAppUrl || 'https://hypothes.is/app.html',
assetRoot: settings.assetRoot || '__ASSET_ROOT__',
manifest: __MANIFEST__,
sidebarAppUrl: settings.sidebarAppUrl || '__SIDEBAR_APP_URL__',
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment