Skip to content

Commit

Permalink
🔧 Makefile : add USE_HOST & USE_HTTPS arguments, keep only one dev co…
Browse files Browse the repository at this point in the history
…mmand
  • Loading branch information
Striffly committed Jun 26, 2024
1 parent 3a0160f commit a94a3a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
.DEFAULT_GOAL := dev
.PHONY: init dev build

# Variable pour l'hôte, valeur par défaut vide
# Exemple d'utilisation : `make dev USE_HOST=true` / `make dev USE_HOST=0.0.0.0`
USE_HOST ?=

# Variable pour activer l'utilisation de HTTPS en dev, valeur par défaut vide
# Exemple d'utilisation : `make dev USE_HTTPS=true`
USE_HTTPS ?= false

# Conditionnelle `HOST` pour inclure ou non l'argument `--host` / `--host=$(HOST)`
HOST_ARG := $(if $(USE_HOST), $(if $(filter true,$(USE_HOST)), --host, --host=$(USE_HOST)))

init:
(cd data && yarn && node export.js)
(cd frontend && yarn)
Expand All @@ -9,10 +20,7 @@ lint: init
(cd frontend && yarn lint)

dev: init
(cd frontend && yarn dev)

dev-host: init
(cd frontend && yarn dev --host)
(cd frontend && USE_HTTPS=$(USE_HTTPS) yarn dev $(HOST_ARG))

build: init
(cd frontend && yarn build)
9 changes: 7 additions & 2 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";
import mkcert from "vite-plugin-mkcert";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), mkcert(), svgr({ include: "**/*.svg" })],
plugins: [
react(),
svgr({ include: "**/*.svg" }),
...(process.env.USE_HTTPS === "true"

Check failure on line 10 in frontend/vite.config.js

View workflow job for this annotation

GitHub Actions / lint

'process' is not defined
? [await import("vite-plugin-mkcert").then((plugin) => plugin.default())]
: []),
],
});

0 comments on commit a94a3a6

Please sign in to comment.