mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2320 from overleaf/as-unify-webpack-output
Unify webpack output GitOrigin-RevId: 5f5ae88f0698236fdce17cf87b4b524078dba4dd
This commit is contained in:
parent
3bad05532a
commit
bf9473fb41
6 changed files with 10 additions and 23 deletions
|
@ -19,15 +19,13 @@ const Modules = require('./Modules')
|
||||||
|
|
||||||
const htmlEncoder = new NodeHtmlEncoder('numerical')
|
const htmlEncoder = new NodeHtmlEncoder('numerical')
|
||||||
|
|
||||||
const jsPath = Settings.useMinifiedJs ? '/minjs/' : '/js/'
|
|
||||||
|
|
||||||
let webpackManifest
|
let webpackManifest
|
||||||
if (!IS_DEV_ENV) {
|
if (!IS_DEV_ENV) {
|
||||||
// Only load webpack manifest file in production. In dev, the web and webpack
|
// Only load webpack manifest file in production. In dev, the web and webpack
|
||||||
// containers can't coordinate, so there no guarantee that the manifest file
|
// containers can't coordinate, so there no guarantee that the manifest file
|
||||||
// exists when the web server boots. We therefore ignore the manifest file in
|
// exists when the web server boots. We therefore ignore the manifest file in
|
||||||
// dev reload
|
// dev reload
|
||||||
webpackManifest = require(`../../../public${jsPath}manifest.json`)
|
webpackManifest = require(`../../../public/js/manifest.json`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileContent(filePath) {
|
function getFileContent(filePath) {
|
||||||
|
@ -133,7 +131,7 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
||||||
// In dev: resolve path within JS asset directory
|
// In dev: resolve path within JS asset directory
|
||||||
// We are *not* guaranteed to have a manifest file when the server
|
// We are *not* guaranteed to have a manifest file when the server
|
||||||
// starts up
|
// starts up
|
||||||
path = Path.join(jsPath, jsFile)
|
path = Path.join('/js', jsFile)
|
||||||
} else {
|
} else {
|
||||||
// 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
|
||||||
|
@ -152,10 +150,6 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
res.locals.buildAssetsPath = function(path) {
|
|
||||||
return `${jsPath}/${path}`
|
|
||||||
}
|
|
||||||
|
|
||||||
res.locals.mathJaxPath = res.locals.buildJsPath('libs/mathjax/MathJax.js', {
|
res.locals.mathJaxPath = res.locals.buildJsPath('libs/mathjax/MathJax.js', {
|
||||||
cdn: false,
|
cdn: false,
|
||||||
qs: { config: 'TeX-AMS_HTML,Safe' }
|
qs: { config: 'TeX-AMS_HTML,Safe' }
|
||||||
|
|
|
@ -137,9 +137,9 @@ block content
|
||||||
window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)};
|
window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)};
|
||||||
window.gitBridgePublicBaseUrl = '#{gitBridgePublicBaseUrl}'
|
window.gitBridgePublicBaseUrl = '#{gitBridgePublicBaseUrl}'
|
||||||
//- Set base path for Ace scripts loaded on demand/workers and don't use cdn
|
//- Set base path for Ace scripts loaded on demand/workers and don't use cdn
|
||||||
window.aceBasePath = "#{buildAssetsPath(lib('ace'))}"
|
window.aceBasePath = "/js/#{lib('ace')}"
|
||||||
//- Set path for PDFjs CMaps
|
//- Set path for PDFjs CMaps
|
||||||
window.pdfCMapsPath = "#{buildAssetsPath('cmaps/')}"
|
window.pdfCMapsPath = "/js/cmaps/"
|
||||||
window.uiConfig = JSON.parse('!{StringHelper.stringifyJsonForScript(uiConfig)}');
|
window.uiConfig = JSON.parse('!{StringHelper.stringifyJsonForScript(uiConfig)}');
|
||||||
//- enable doc hash checking for all projects
|
//- enable doc hash checking for all projects
|
||||||
//- used in public/js/libs/sharejs.js
|
//- used in public/js/libs/sharejs.js
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
"nodemon": "nodemon --config nodemon.json",
|
"nodemon": "nodemon --config nodemon.json",
|
||||||
"nodemon:frontend": "nodemon --config nodemon.frontend.json",
|
"nodemon:frontend": "nodemon --config nodemon.frontend.json",
|
||||||
"webpack": "webpack-dev-server --config webpack.config.dev.js",
|
"webpack": "webpack-dev-server --config webpack.config.dev.js",
|
||||||
"webpack:production": "webpack --config webpack.config.prod.js",
|
"webpack:production": "webpack --config webpack.config.prod.js && cp -R public/js public/minjs",
|
||||||
"lint": "eslint -f unix .",
|
"lint": "eslint -f unix .",
|
||||||
"format": "prettier-eslint '**/*.js' --list-different",
|
"format": "prettier-eslint '**/*.js' --list-different",
|
||||||
"format:fix": "prettier-eslint '**/*.js' --write",
|
"format:fix": "prettier-eslint '**/*.js' --write",
|
||||||
|
|
|
@ -8,10 +8,6 @@ module.exports = merge(base, {
|
||||||
// Enable source maps for dev (fast compilation, slow runtime)
|
// Enable source maps for dev (fast compilation, slow runtime)
|
||||||
devtool: 'cheap-module-eval-source-map',
|
devtool: 'cheap-module-eval-source-map',
|
||||||
|
|
||||||
output: {
|
|
||||||
publicPath: '/js/'
|
|
||||||
},
|
|
||||||
|
|
||||||
devServer: {
|
devServer: {
|
||||||
// Disable webpack dev server auto-reload
|
// Disable webpack dev server auto-reload
|
||||||
inline: false,
|
inline: false,
|
||||||
|
|
|
@ -14,9 +14,9 @@ const entryPoints = {
|
||||||
ide: './frontend/js/ide.js'
|
ide: './frontend/js/ide.js'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to load frontend entry-points from modules, if they exist
|
||||||
if (fs.existsSync(MODULES_PATH)) {
|
if (fs.existsSync(MODULES_PATH)) {
|
||||||
fs.readdirSync(MODULES_PATH).reduce((acc, module) => {
|
fs.readdirSync(MODULES_PATH).reduce((acc, module) => {
|
||||||
// FIXME: modules frontend path
|
|
||||||
const entryPath = path.join(MODULES_PATH, module, '/frontend/js/index.js')
|
const entryPath = path.join(MODULES_PATH, module, '/frontend/js/index.js')
|
||||||
if (fs.existsSync(entryPath)) {
|
if (fs.existsSync(entryPath)) {
|
||||||
acc[module] = entryPath
|
acc[module] = entryPath
|
||||||
|
@ -36,6 +36,9 @@ module.exports = {
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, '/public/js'),
|
path: path.join(__dirname, '/public/js'),
|
||||||
|
|
||||||
|
// Serve from /js
|
||||||
|
publicPath: '/js/',
|
||||||
|
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
|
|
||||||
// Output as UMD bundle (allows main JS to import with CJS, AMD or global
|
// Output as UMD bundle (allows main JS to import with CJS, AMD or global
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
const path = require('path')
|
|
||||||
const merge = require('webpack-merge')
|
const merge = require('webpack-merge')
|
||||||
|
|
||||||
const base = require('./webpack.config')
|
const base = require('./webpack.config')
|
||||||
|
@ -10,12 +9,7 @@ module.exports = merge(base, {
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
// Override output path to minjs dir
|
|
||||||
path: path.join(__dirname, '/public/minjs'),
|
|
||||||
|
|
||||||
// Override filename to include hash for immutable caching
|
// Override filename to include hash for immutable caching
|
||||||
filename: '[name]-[chunkhash].js',
|
filename: '[name]-[chunkhash].js'
|
||||||
|
|
||||||
publicPath: '/minjs/'
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue