Completely integrate wepack in django

* Migrate alpine
* Migrate jquery and jquery-ui
* Migrate shorten
* Add babel for javascript
* Introduce staticfiles django app
* Only bundle -index.js files in static/webpack
* Unify scss and webpack generated files
* Convert scss calls to static
* Add --clear-generated option to collectstatic
* Fix docs warnings
This commit is contained in:
2024-09-17 23:42:05 +02:00
committed by Bartuccio Antoine
parent 71c96fdf62
commit 655d72a2b1
86 changed files with 6170 additions and 1268 deletions

View File

@ -7,34 +7,33 @@
<link rel="shortcut icon" href="{{ static('core/img/favicon.ico') }}">
<link rel="stylesheet" href="{{ static('core/base.css') }}">
<link rel="stylesheet" href="{{ static('ajax_select/css/ajax_select.css') }}">
<link rel="stylesheet" href="{{ scss('core/style.scss') }}">
<link rel="stylesheet" href="{{ scss('core/markdown.scss') }}">
<link rel="stylesheet" href="{{ scss('core/header.scss') }}">
<link rel="stylesheet" href="{{ scss('core/navbar.scss') }}">
<link rel="stylesheet" href="{{ scss('core/pagination.scss') }}">
<link rel="stylesheet" href="{{ static('core/style.scss') }}">
<link rel="stylesheet" href="{{ static('core/markdown.scss') }}">
<link rel="stylesheet" href="{{ static('core/header.scss') }}">
<link rel="stylesheet" href="{{ static('core/navbar.scss') }}">
<link rel="stylesheet" href="{{ static('core/pagination.scss') }}">
<link rel="stylesheet" href="{{ static('vendored/select2/select2.min.css') }}">
{% block jquery_css %}
{# Thile file is quite heavy (around 250kb), so declaring it in a block allows easy removal #}
<link rel="stylesheet" href="{{ static('vendored/jquery/ui/jquery-ui.min.css') }}">
<link rel="stylesheet" href="{{ static('webpack/jquery-index.css') }}">
{% endblock %}
<link rel="preload" as="style" href="{{ static('vendored/font-awesome/css/font-awesome.min.css') }}" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="{{ static('vendored/font-awesome/css/font-awesome.min.css') }}"></noscript>
<script defer href="{{ static('vendored/font-awesome/js/fontawesome.min.js') }}"></script>
<script src="{{ static('webpack/alpine-index.js') }}" defer></script>
<!-- Jquery declared here to be accessible in every django widgets -->
<script src="{{ static('vendored/jquery/jquery-3.6.2.min.js') }}"></script>
<script src="{{ static('webpack/jquery-index.js') }}"></script>
<!-- Put here to always have acces to those functions on django widgets -->
<script src="{{ static('core/js/script.js') }}"></script>
<script defer src="{{ static('vendored/select2/select2.min.js') }}"></script>
<script defer src="{{ static('core/js/sith-select2.js') }}"></script>
{% block additional_css %}{% endblock %}
{% block additional_js %}{% endblock %}
{# Alpine JS must be loaded after scripts that use it. #}
<script src="{{ static('vendored/alpine/alpinejs.min.js') }}" defer></script>
{% endblock %}
</head>
@ -299,7 +298,6 @@
{% endif %}
{% block script %}
<script src="{{ static('vendored/jquery/ui/jquery-ui.min.js') }}"></script>
<script src="{{ static('ajax_select/js/ajax_select.js') }}"></script>
<script src="{{ url('javascript-catalog') }}"></script>
<script>

View File

@ -1,7 +1,7 @@
{% extends "core/base.jinja" %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/login.scss') }}">
<link rel="stylesheet" href="{{ static('user/login.scss') }}">
{%- endblock -%}
{% block title %}

View File

@ -1,7 +1,7 @@
{% extends "core/base.jinja" %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/login.scss') }}">
<link rel="stylesheet" href="{{ static('user/login.scss') }}">
{%- endblock -%}
{% block title %}{% trans %}Register{% endtrans %}{% endblock %}

View File

@ -2,7 +2,7 @@
<html lang="fr">
<head>
<title>{% trans %}Slideshow{% endtrans %}</title>
<link href="{{ scss('com/css/slideshow.scss') }}" rel="stylesheet" type="text/css" />
<link href="{{ static('com/css/slideshow.scss') }}" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="slideshow">

View File

@ -2,7 +2,7 @@
{% from "core/macros.jinja" import show_slots, show_tokens, user_subscription %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/user_detail.scss') }}">
<link rel="stylesheet" href="{{ static('user/user_detail.scss') }}">
{%- endblock -%}
{% block title %}

View File

@ -5,7 +5,7 @@
{%- endblock -%}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/user_edit.scss') }}">
<link rel="stylesheet" href="{{ static('user/user_edit.scss') }}">
{%- endblock -%}
{% block additional_js %}

View File

@ -2,7 +2,7 @@
{% from "core/macros.jinja" import user_link_with_pict, delete_godfather %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/user_godfathers.scss') }}">
<link rel="stylesheet" href="{{ static('user/user_godfathers.scss') }}">
{%- endblock -%}
{% block title %}

View File

@ -3,7 +3,7 @@
{% set depth_max=10 %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/user_godfathers.scss') }}">
<link rel="stylesheet" href="{{ static('user/user_godfathers.scss') }}">
{%- endblock -%}
{% block additional_js %}

View File

@ -1,7 +1,7 @@
{% extends "core/base.jinja" %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/user_group.scss') }}">
<link rel="stylesheet" href="{{ static('user/user_group.scss') }}">
{%- endblock -%}
{% block content %}

View File

@ -1,7 +1,7 @@
{% extends "core/base.jinja" %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('sas/css/album.scss') }}">
<link rel="stylesheet" href="{{ static('sas/css/album.scss') }}">
{%- endblock -%}
{% block additional_js %}

View File

@ -1,7 +1,7 @@
{% extends "core/base.jinja" %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/user_preferences.scss') }}">
<link rel="stylesheet" href="{{ static('user/user_preferences.scss') }}">
{%- endblock -%}
{% block title %}

View File

@ -1,7 +1,7 @@
{% extends "core/base.jinja" %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/user_stats.scss') }}">
<link rel="stylesheet" href="{{ static('user/user_stats.scss') }}">
{%- endblock -%}
{% block title %}

View File

@ -1,7 +1,7 @@
{% extends "core/base.jinja" %}
{%- block additional_css -%}
<link rel="stylesheet" href="{{ scss('user/user_tools.scss') }}">
<link rel="stylesheet" href="{{ static('user/user_tools.scss') }}">
{%- endblock -%}
{% block title %}