diff --git a/services/web/Dockerfile b/services/web/Dockerfile index 5dcd9760b6..fd6d2d4abd 100644 --- a/services/web/Dockerfile +++ b/services/web/Dockerfile @@ -36,6 +36,13 @@ ENV CYPRESS_INSTALL_BINARY=0 RUN cd /overleaf && npm install +# the web image with only production dependencies but no webpack production build, for development +FROM deps-prod as app-only + +COPY services/web /overleaf/services/web +USER node + +CMD ["node", "--expose-gc", "app.js"] # the dev is suitable for running tests FROM deps as dev diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js index 9f1759519a..6b979cc47e 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.js +++ b/services/web/app/src/infrastructure/ExpressLocals.js @@ -196,11 +196,7 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) { } )}` - res.locals.mathJax3Path = `/js/libs/mathjax3/es5/tex-svg-full.js?${querystring.stringify( - { - v: PackageVersions.version['mathjax-3'], - } - )}` + res.locals.mathJax3Path = `/js/libs/mathjax-3-${PackageVersions.version['mathjax-3']}/es5/tex-svg-full.js` res.locals.lib = PackageVersions.lib diff --git a/services/web/cypress/support/shared/commands/mathjax.ts b/services/web/cypress/support/shared/commands/mathjax.ts index c99fb5c2a8..73ed175318 100644 --- a/services/web/cypress/support/shared/commands/mathjax.ts +++ b/services/web/cypress/support/shared/commands/mathjax.ts @@ -1,8 +1,8 @@ const MATHJAX_STUB = ` -window.MathJax = { +window.MathJax = { startup: { promise: Promise.resolve() - }, + }, svgStylesheet: () => document.createElement("STYLE"), typesetPromise: (elements) => { for (const element of elements) { @@ -23,15 +23,10 @@ window.MathJax = { ` export const interceptMathJax = () => { + // NOTE: this is just a URL to be intercepted with the stub, not the real (versioned) MathJax URL + const url = '/js/libs/mathjax-3/es5/tex-svg-full.js' cy.window().then(win => { - win.metaAttributesCache.set( - 'ol-mathJax3Path', - '/js/libs/mathjax3/es5/tex-svg-full.js' - ) + win.metaAttributesCache.set('ol-mathJax3Path', url) }) - cy.intercept( - 'GET', - '/js/libs/mathjax3/es5/tex-svg-full.js*', - MATHJAX_STUB - ).as('mathjax-load-request') + cy.intercept('GET', url, MATHJAX_STUB).as('mathjax-load-request') } diff --git a/services/web/webpack.config.js b/services/web/webpack.config.js index 83c8ef02e7..6da8f627f6 100644 --- a/services/web/webpack.config.js +++ b/services/web/webpack.config.js @@ -284,17 +284,20 @@ module.exports = { // https://www.npmjs.com/package/mathjax#user-content-hosting-your-own-copy-of-the-mathjax-components { from: 'es5/tex-svg-full.js', - to: 'js/libs/mathjax3/es5', + to: `js/libs/mathjax-3-${PackageVersions.version['mathjax-3']}/es5`, + toType: 'dir', context: mathjax3Dir, }, { from: 'es5/input/tex/extensions/**/*.js', - to: 'js/libs/mathjax3', + to: `js/libs/mathjax-3-${PackageVersions.version['mathjax-3']}`, + toType: 'dir', context: mathjax3Dir, }, { from: 'es5/ui/**/*', - to: 'js/libs/mathjax3', + to: `js/libs/mathjax-3-${PackageVersions.version['mathjax-3']}`, + toType: 'dir', context: mathjax3Dir, }, { from: 'MathJax.js', to: 'js/libs/mathjax', context: mathjaxDir },