Skip to content

Commit

Permalink
Merge pull request #26
Browse files Browse the repository at this point in the history
fix static and remove no used lib
  • Loading branch information
lihuacai168 authored Nov 19, 2022
2 parents a4ddec0 + 665fae9 commit 8058b59
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
28 changes: 3 additions & 25 deletions FasterRunner/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,10 @@
"django_celery_beat",
"rest_framework_swagger",
"drf_yasg",
"compressor",
]

MIDDLEWARE = [
"django.middleware.gzip.GZipMiddleware",
"htmlmin.middleware.HtmlMinifyMiddleware",
"htmlmin.middleware.MarkRequestMiddleware",
"log_request_id.middleware.RequestIDMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
Expand All @@ -77,28 +74,9 @@
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = "/static/"

STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
# Add this
"compressor.finders.CompressorFinder",
)
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
COMPRESS_ROOT = os.path.join(BASE_DIR, "static")
STATIC_ROOT = os.path.join(BASE_DIR, "static_root")
COMPRESS_ENABLED = True
COMPRESS_CSS_HASHING_METHOD = "content"
COMPRESS_FILTERS = {
"css": [
"compressor.filters.css_default.CssAbsoluteFilter",
"compressor.filters.cssmin.rCSSMinFilter",
],
"js": [
"compressor.filters.jsmin.JSMinFilter",
],
}
HTML_MINIFY = True
KEEP_COMMENTS_ON_MINIFYING = True
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] # 指定static文件的路径,缺少这个配置,collect static 无法加载extent.js

STATIC_ROOT = os.path.join(BASE_DIR, "static_root") # collect static 之后的文件存放路径

ROOT_URLCONF = "FasterRunner.urls"

Expand Down
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,4 @@ pydantic==1.9.0
gunicorn
sentry-sdk~=1.5.8
croniter~=1.3.5 # 计算下一次crontab
django-log-request-id~=2.0.0

django-htmlmin==0.11.0
django-compressor==2.3 # 压缩静态文件
django-log-request-id~=2.0.0
3 changes: 0 additions & 3 deletions templates/report_template.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% load static %}

{% load compress %}
<!DOCTYPE html>
<html>

Expand Down Expand Up @@ -8477,9 +8476,7 @@ <h5 class='category-name'></h5>

</script>

{% compress js %}
<script src="{% static 'extent.js' %}" type='text/javascript'></script>
{% endcompress js %}

<script type='text/javascript'>
$(window).off("keydown");
Expand Down

0 comments on commit 8058b59

Please sign in to comment.