mirror of https://github.com/zulip/zulip.git
storage: Remove RemoveUnminifiedFilesMixin.
This can be done much more easily with the right options to collectstatic. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
f47f98e2f1
commit
b0a30aa01a
|
@ -57,7 +57,7 @@ run(['./tools/webpack'], stdout=fp, stderr=fp)
|
||||||
|
|
||||||
# Collect the files that we're going to serve; this creates prod-static/serve.
|
# Collect the files that we're going to serve; this creates prod-static/serve.
|
||||||
run(['./manage.py', 'collectstatic', '--no-default-ignore',
|
run(['./manage.py', 'collectstatic', '--no-default-ignore',
|
||||||
'--noinput', '-i', 'assets', '-i', 'styles', '-i', 'templates'],
|
'--noinput', '-i', 'assets', '-i', 'js', '-i', 'styles', '-i', 'templates'],
|
||||||
stdout=fp, stderr=fp)
|
stdout=fp, stderr=fp)
|
||||||
|
|
||||||
if not settings.PRODUCTION:
|
if not settings.PRODUCTION:
|
||||||
|
|
|
@ -1,34 +1,12 @@
|
||||||
# Useful reading is https://zulip.readthedocs.io/en/latest/subsystems/front-end-build-process.html
|
# Useful reading is https://zulip.readthedocs.io/en/latest/subsystems/front-end-build-process.html
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
from typing import Optional
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
|
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
|
||||||
from pipeline.storage import PipelineMixin
|
from pipeline.storage import PipelineMixin
|
||||||
|
|
||||||
class RemoveUnminifiedFilesMixin:
|
|
||||||
def post_process(self, paths: Dict[str, Tuple['ZulipStorage', str]], dry_run: bool=False,
|
|
||||||
**kwargs: Any) -> List[Tuple[str, str, bool]]:
|
|
||||||
if dry_run:
|
|
||||||
return []
|
|
||||||
|
|
||||||
root = settings.STATIC_ROOT
|
|
||||||
to_remove = ['js']
|
|
||||||
|
|
||||||
for tree in to_remove:
|
|
||||||
shutil.rmtree(os.path.join(root, tree))
|
|
||||||
|
|
||||||
is_valid = lambda p: all([not p.startswith(k) for k in to_remove])
|
|
||||||
|
|
||||||
paths = {k: v for k, v in paths.items() if is_valid(k)}
|
|
||||||
super_class = super()
|
|
||||||
if hasattr(super_class, 'post_process'):
|
|
||||||
return super_class.post_process(paths, dry_run, **kwargs) # type: ignore # https://github.com/python/mypy/issues/2956
|
|
||||||
|
|
||||||
return []
|
|
||||||
|
|
||||||
class IgnoreBundlesManifestStaticFilesStorage(ManifestStaticFilesStorage):
|
class IgnoreBundlesManifestStaticFilesStorage(ManifestStaticFilesStorage):
|
||||||
def hashed_name(self, name: str, content: Optional[str]=None, filename: Optional[str]=None) -> str:
|
def hashed_name(self, name: str, content: Optional[str]=None, filename: Optional[str]=None) -> str:
|
||||||
ext = os.path.splitext(name)[1]
|
ext = os.path.splitext(name)[1]
|
||||||
|
@ -75,6 +53,5 @@ if settings.PRODUCTION:
|
||||||
ManifestStaticFilesStorage.path = path
|
ManifestStaticFilesStorage.path = path
|
||||||
|
|
||||||
class ZulipStorage(PipelineMixin,
|
class ZulipStorage(PipelineMixin,
|
||||||
RemoveUnminifiedFilesMixin,
|
|
||||||
IgnoreBundlesManifestStaticFilesStorage):
|
IgnoreBundlesManifestStaticFilesStorage):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue