Skip to content
Snippets Groups Projects

Resolve "Evaluate use of Vite instead of Webpack"

Merged Nik | Klampfradler requested to merge 769-evaluate-use-of-vite-instead-of-webpack into master
7 files
+ 52
133
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -11,25 +11,29 @@ from ...util.frontend_helpers import get_apps_with_assets
class Command(BaseYarnCommand):
help = "Create webpack bundles for AlekSIS" # noqa
help = "Create Vite bundles for AlekSIS" # noqa
def handle(self, *args, **options):
super(Command, self).handle(*args, **options)
# Write webpack entrypoints for all apps
assets = {
app: {"dependOn": "core", "import": os.path.join(path, "index")}
# Inject settings into Vite
vite_values = {
"static_url": settings.STATIC_URL,
}
# Write rollup entrypoints for all apps
vite_values["entrypoints"] = {
app: os.path.join(path, "index")
for app, path in get_apps_with_assets().items()
}
assets["core"] = os.path.join(settings.BASE_DIR, "aleksis", "core", "assets", "index")
with open(os.path.join(settings.NODE_MODULES_ROOT, "webpack-entrypoints.json"), "w") as out:
json.dump(assets, out)
vite_values["entrypoints"]["core"] = os.path.join(settings.BASE_DIR, "aleksis", "core", "assets", "index")
with open(os.path.join(settings.NODE_MODULES_ROOT, "django-vite-values.json"), "w") as out:
json.dump(vite_values, out)
# Install Node dependencies
yarn_adapter.install(settings.YARN_INSTALLED_APPS)
# Run webpack
config_path = os.path.join(settings.BASE_DIR, "aleksis", "core", "webpack.config.js")
# Run Vite
config_path = os.path.join(settings.BASE_DIR, "aleksis", "core", "vite.config.js")
shutil.copy(config_path, settings.NODE_MODULES_ROOT)
mode = "development" if settings.DEBUG else "production"
yarn_adapter.call_yarn(["run", "webpack", f"--mode={mode}"])
yarn_adapter.call_yarn(["run", "vite", "build", "-m", mode, "-l", "info", "-d"])
Loading