static: Serve webpack bundles from the root domain.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-04-03 16:47:18 -07:00
committed by Tim Abbott
parent 038b315d8e
commit 99242138a7
11 changed files with 54 additions and 10 deletions

View File

@@ -15,6 +15,7 @@ import os
import time
import sys
from typing import Any, Dict, List, Union
from urllib.parse import urljoin
from zerver.lib.db import TimeTrackingConnection
import zerver.lib.logging_util
@@ -516,7 +517,10 @@ if CAMO_URI != '':
# STATIC CONTENT AND MINIFICATION SETTINGS
########################################################################
STATIC_URL = '/static/'
if PRODUCTION or os.getenv('EXTERNAL_HOST') is not None:
STATIC_URL = urljoin(ROOT_DOMAIN_URI, '/static/')
else:
STATIC_URL = 'http://localhost:9991/static/'
# ZulipStorage is a modified version of ManifestStaticFilesStorage,
# and, like that class, it inserts a file hash into filenames
@@ -549,7 +553,7 @@ else:
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
'BUNDLE_DIR_NAME': 'webpack-bundles/',
'BUNDLE_DIR_NAME': '../webpack/' if DEBUG else 'webpack-bundles/',
'STATS_FILE': os.path.join(DEPLOY_ROOT, WEBPACK_STATS_FILE),
}
}