|
@@ -77,6 +77,12 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
|
|
staticFilesBase = ''
|
|
staticFilesBase = ''
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ res.locals.buildBaseAssetPath = function() {
|
|
|
|
|
+ // Return the base asset path (including the CDN url) so that webpack can
|
|
|
|
|
+ // use this to dynamically fetch scripts (e.g. PDFjs worker)
|
|
|
|
|
+ return Url.resolve(staticFilesBase, '/')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
res.locals.buildJsPath = function(jsFile) {
|
|
res.locals.buildJsPath = function(jsFile) {
|
|
|
let path
|
|
let path
|
|
|
if (IS_DEV_ENV) {
|
|
if (IS_DEV_ENV) {
|
|
@@ -88,7 +94,7 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
|
|
// In production: resolve path from webpack manifest file
|
|
// In production: resolve path from webpack manifest file
|
|
|
// We are guaranteed to have a manifest file since webpack compiles in
|
|
// We are guaranteed to have a manifest file since webpack compiles in
|
|
|
// the build
|
|
// the build
|
|
|
- path = webpackManifest[jsFile]
|
|
|
|
|
|
|
+ path = `/${webpackManifest[jsFile]}`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return Url.resolve(staticFilesBase, path)
|
|
return Url.resolve(staticFilesBase, path)
|
|
@@ -96,7 +102,7 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
|
|
|
|
|
|
|
// Temporary hack while jQuery/Angular dependencies are *not* bundled,
|
|
// Temporary hack while jQuery/Angular dependencies are *not* bundled,
|
|
|
// instead copied into output directory
|
|
// instead copied into output directory
|
|
|
- res.locals.buildCopiedJsAssetPath = function(jsFile, opts = {}) {
|
|
|
|
|
|
|
+ res.locals.buildCopiedJsAssetPath = function(jsFile) {
|
|
|
let path
|
|
let path
|
|
|
if (IS_DEV_ENV) {
|
|
if (IS_DEV_ENV) {
|
|
|
// In dev: resolve path to root directory
|
|
// In dev: resolve path to root directory
|
|
@@ -107,27 +113,17 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
|
|
// In production: resolve path from webpack manifest file
|
|
// In production: resolve path from webpack manifest file
|
|
|
// We are guaranteed to have a manifest file since webpack compiles in
|
|
// We are guaranteed to have a manifest file since webpack compiles in
|
|
|
// the build
|
|
// the build
|
|
|
- path = webpackManifest[jsFile]
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (opts.cdn !== false) {
|
|
|
|
|
- path = Url.resolve(staticFilesBase, path)
|
|
|
|
|
|
|
+ path = `/${webpackManifest[jsFile]}`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (opts.qs) {
|
|
|
|
|
- path = path + '?' + querystring.stringify(opts.qs)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return path
|
|
|
|
|
|
|
+ return Url.resolve(staticFilesBase, path)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- res.locals.mathJaxPath = res.locals.buildCopiedJsAssetPath(
|
|
|
|
|
- 'js/libs/mathjax/MathJax.js',
|
|
|
|
|
|
|
+ res.locals.mathJaxPath = `/js/libs/mathjax/MathJax.js?${querystring.stringify(
|
|
|
{
|
|
{
|
|
|
- cdn: false,
|
|
|
|
|
- qs: { config: 'TeX-AMS_HTML,Safe' }
|
|
|
|
|
|
|
+ config: 'TeX-AMS_HTML,Safe'
|
|
|
}
|
|
}
|
|
|
- )
|
|
|
|
|
|
|
+ )}`
|
|
|
|
|
|
|
|
res.locals.lib = PackageVersions.lib
|
|
res.locals.lib = PackageVersions.lib
|
|
|
|
|
|
|
@@ -168,7 +164,7 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
|
|
// In production: resolve path from webpack manifest file
|
|
// In production: resolve path from webpack manifest file
|
|
|
// We are guaranteed to have a manifest file since webpack compiles in
|
|
// We are guaranteed to have a manifest file since webpack compiles in
|
|
|
// the build
|
|
// the build
|
|
|
- path = webpackManifest[cssFileName]
|
|
|
|
|
|
|
+ path = `/${webpackManifest[cssFileName]}`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return Url.resolve(staticFilesBase, path)
|
|
return Url.resolve(staticFilesBase, path)
|