mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
Ever since we started bundling the app with webpack, there’s been less and less overlap between our ‘static’ directory (files belonging to the frontend app) and Django’s interpretation of the ‘static’ directory (files served directly to the web). Split the app out to its own ‘web’ directory outside of ‘static’, and remove all the custom collectstatic --ignore rules. This makes it much clearer what’s actually being served to the web, and what’s being bundled by webpack. It also shrinks the release tarball by 3%. Signed-off-by: Anders Kaseorg <anders@zulip.com>
59 lines
1.5 KiB
Python
Executable File
59 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Updates static files for production.
|
|
import os
|
|
import sys
|
|
|
|
# We need settings so we can figure out where the prod-static directory is.
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
from scripts.lib.setup_path import setup_path
|
|
|
|
setup_path()
|
|
|
|
# check for the venv
|
|
from tools.lib import sanity_check
|
|
|
|
sanity_check.check_venv(__file__)
|
|
|
|
os.environ["DJANGO_SETTINGS_MODULE"] = "zproject.settings"
|
|
os.environ["ZULIP_COLLECTING_STATIC"] = "1"
|
|
from django.conf import settings
|
|
|
|
from scripts.lib.node_cache import setup_node_modules
|
|
from scripts.lib.zulip_tools import assert_not_running_as_root, run
|
|
|
|
assert_not_running_as_root()
|
|
|
|
|
|
os.chdir(settings.DEPLOY_ROOT)
|
|
|
|
# Install node packages
|
|
setup_node_modules(production=True)
|
|
|
|
# Build emoji
|
|
run(["./tools/setup/emoji/build_emoji"])
|
|
|
|
# Inline CSS in emails
|
|
run(["./scripts/setup/inline_email_css.py"])
|
|
|
|
# Copy over static files from the zulip_bots package
|
|
run(["./tools/setup/generate_zulip_bots_static_files.py"])
|
|
|
|
# Build pygments data
|
|
run(["./tools/setup/build_pygments_data"])
|
|
|
|
# Build time zone data
|
|
run(["./tools/setup/build_timezone_values"])
|
|
|
|
# Create webpack bundle
|
|
run(["./tools/webpack", "--quiet"])
|
|
|
|
# Collect the files that we're going to serve; this creates prod-static/serve.
|
|
run(["./manage.py", "collectstatic", "-v0", "--noinput"])
|
|
|
|
# Compile translation strings to generate `.mo` files.
|
|
run(["./manage.py", "compilemessages", "-v0"])
|
|
|
|
# Needed if PRODUCTION
|
|
os.makedirs("prod-static", exist_ok=True)
|