Setup static file pipeline

This commit is contained in:
Jake Howard 2022-06-10 09:13:00 +01:00
parent 56112a9655
commit c1fdd81f86
Signed by: jake
GPG key ID: 57AFB45680EDD477
9 changed files with 2582 additions and 14 deletions

View file

@ -1 +1,3 @@
web: ./manage.py runserver
watch-js: npm run build:js -- --watch
watch-css: npm run build:css -- --watch

2568
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,15 @@
"description": "",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build:js": "esbuild static/src/js/*.js --bundle --outdir=static/build/js --minify --sourcemap",
"build:css": "sass --style=compressed static/src/scss:static/build/css",
"build": "npm-run-all build:*"
},
"author": "Jake Howard"
"author": "Jake Howard",
"devDependencies": {
"esbuild": "^0.14.43",
"npm-run-all": "^4.1.5",
"sass": "^1.52.3"
}
}

View file

View file

@ -17,7 +17,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
{# Global stylesheets #}
<link rel="stylesheet" type="text/css" href="{% static 'css/website.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/index.css' %}">
{% block extra_css %}
{# Override this in templates to add extra stylesheets #}
@ -30,7 +30,7 @@
{% block content %}{% endblock %}
{# Global javascript #}
<script type="text/javascript" src="{% static 'js/website.js' %}"></script>
<script type="text/javascript" src="{% static 'js/index.js' %}"></script>
{% block extra_js %}
{# Override this in templates to add extra javascript #}

View file

@ -3,14 +3,6 @@
{% block body_class %}template-homepage{% endblock %}
{% block extra_css %}
{% comment %}
Delete the line below if you're just getting started and want to remove the welcome screen!
{% endcomment %}
<link rel="stylesheet" href="{% static 'css/welcome_page.css' %}">
{% endblock extra_css %}
{% block content %}
{% comment %}

View file

@ -107,7 +107,7 @@ STATICFILES_FINDERS = [
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
os.path.join(BASE_DIR, "static", "build"),
]
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"