Просмотр исходного кода

Merge pull request #15629 from overleaf/ae-web-target

Use production `web` dependencies for development

GitOrigin-RevId: e89942d1a24c32bf60b319932c6d74905db74a19
Alf Eaton 2 лет назад
Родитель
Сommit
3912de589f

+ 7 - 0
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

+ 1 - 5
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
 

+ 6 - 11
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')
 }

+ 6 - 3
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 },