webpack: Build a ZULIP_VERSION global constant into the built product.

This commit is contained in:
Alex Vandiver
2023-03-03 21:38:01 +00:00
committed by Tim Abbott
parent 73631950a5
commit a8181152b7
4 changed files with 24 additions and 2 deletions

View File

@@ -3,11 +3,17 @@ import argparse
import json
import os
import subprocess
import sys
from typing import NoReturn
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
os.chdir(os.path.join(os.path.dirname(__file__), "../web"))
from version import ZULIP_VERSION
def build_for_prod_or_puppeteer(quiet: bool) -> NoReturn:
"""Builds for production, writing the output to disk"""
@@ -15,7 +21,11 @@ def build_for_prod_or_puppeteer(quiet: bool) -> NoReturn:
with open("/proc/meminfo") as meminfo:
if int(next(meminfo).split()[1]) < 3 * 1024 * 1024:
webpack_args += ["--max-old-space-size=1536"]
webpack_args += ["../node_modules/.bin/webpack-cli", "--mode=production"]
webpack_args += [
"../node_modules/.bin/webpack-cli",
"--mode=production",
f"--env=ZULIP_VERSION={ZULIP_VERSION}",
]
if quiet:
webpack_args += ["--stats=errors-only"]
os.execvp(webpack_args[0], webpack_args)