Merge pull request #5040 from overleaf/jpa-web-templates-page

[web] v2-templates module: refactor frontend entrypoint into page

GitOrigin-RevId: 2efe344167cba3111eb516ebc2dfadd82347f776
This commit is contained in:
Jakob Ackermann 2021-09-15 14:24:11 +02:00 committed by Copybot
parent 7923ceda6d
commit 23c4f9462b

View file

@ -1,4 +1,3 @@
const fs = require('fs')
const path = require('path')
const glob = require('glob')
const webpack = require('webpack')
@ -8,8 +7,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const PackageVersions = require('./app/src/infrastructure/PackageVersions')
const MODULES_PATH = path.join(__dirname, '/modules')
// Generate a hash of entry points, including modules
const entryPoints = {
serviceWorker: './frontend/js/serviceWorker.js',
@ -22,17 +19,6 @@ const entryPoints = {
'light-style': './frontend/stylesheets/light-style.less',
}
// Attempt to load frontend entry-points from modules, if they exist
if (fs.existsSync(MODULES_PATH)) {
fs.readdirSync(MODULES_PATH).reduce((acc, module) => {
const entryPath = path.join(MODULES_PATH, module, '/frontend/js/index.js')
if (fs.existsSync(entryPath)) {
acc[module] = entryPath
}
return acc
}, entryPoints)
}
// Add entrypoints for each "page"
glob
.sync(path.join(__dirname, 'modules/*/frontend/js/pages/**/*.js'))