Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/static/production-build.py
Views: 687
#!/usr/bin/env python312import json, os, shutil345def handle_path(s, path=None):6desc = s7if path is not None:8os.chdir(path)9desc += " # in '%s'" % path10print(desc)111213def cmd(s, path=None):14home = os.path.abspath(os.curdir)15try:16handle_path(s, path)17if os.system(s):18raise RuntimeError("Error executing '%s'" % s)19finally:20os.chdir(home)212223def app_version():24# We also create a versioned app.html file, named "app-[version].html", where25# version is taken from package.json. We do this entirely so we easily26# run specific versions of the cocalc client code by slightly changing27# the URL. Nothing else should depend on this.28version = json.loads(open('package.json').read())['version']29cmd(f"cp dist/app.html dist/app-{version}.html")303132def main():33# Build with production BASE_PATH='/'. Note that we also disable disk caching for production builds,34# since disk caching **does** randomly break (maybe 10% chance), and despite the speedups, it35# is just not worth the risk for production builds!!! If webpack fixes their disk caching bugs,36# maybe change this; this may take time, since I couldn't find a reported bug about this now.37#38# TODO -- this is dumb and we must get rid of hardcoding of the base url. But that is another problem for later...39NODE_ENV = os.environ.get('NODE_ENV', 'production')40cmd(f"NODE_ENV={NODE_ENV} rspack"41)42app_version()434445if __name__ == "__main__":46main()474849