Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use elm-watch #160

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MATOMO_TOKEN=xxx
SENTRY_DSN=https://[email protected]/xxx
VITE_MATOMO_TOKEN=xxx
VITE_SENTRY_DSN=https://[email protected]/xxx
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
/public/icomoon/*.txt
/public/icomoon/*.zip
/public/icomoon/demo-files
/public/icomoon/demo-files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing this line? We don't want to version icomoon HTML demo files…

/public/icomoon/demo.html
/public/main.css
/public/main.css.map
/public/build
/server-app.js
/tests/TestDb.elm
/xls
/public/version.json
/.parcel-cache/
/.parcel-cache/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Chaque _Pull Request_ effectuée sur le dépôt est également automatiquement d

Certaines variables d'environnement peuvent ou doivent être configurées via l'interface de [configuration Scalingo](https://dashboard.scalingo.com/apps/osc-fr1/wikicarbone/environment) :

- `SENTRY_DSN`: le DSN [Sentry](https://sentry.io) à utiliser pour les rapports d'erreur.
- `MATOMO_TOKEN`: le token [Matomo](https://stats.data.gouv.fr/) permettant le suivi d'audience de l'API.
- `VITE_SENTRY_DSN`: le DSN [Sentry](https://sentry.io) à utiliser pour les rapports d'erreur.
- `VITE_MATOMO_TOKEN`: le token [Matomo](https://stats.data.gouv.fr/) permettant le suivi d'audience de l'API.
Comment on lines +73 to +74
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: It's annoying these must be prefixed; no way to avoid it?


## Lancement du serveur

Expand Down
20 changes: 20 additions & 0 deletions elm-watch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"postprocess": [
"elm-watch-node",
"postprocess.mjs"
],
"targets": {
"frontend": {
"inputs": [
"src/Main.elm"
],
"output": "public/build/main.js"
},
"server": {
"inputs": [
"src/Server.elm"
],
"output": "server-app.js"
}
}
}
39 changes: 22 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Ecobalyse</title>
<link rel="canonical" href="https://ecobalyse.beta.gouv.fr/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Accélerer la mise en place de l'affichage environnemental">
<meta name="theme-color" content="#333333">
<link rel="icon" type="image/svg" href="./public/img/logo.svg">
<link href="./public/icomoon/style.css" rel="stylesheet">
<link href="./styles.scss" rel="stylesheet">
<script type="module" src="index.js"></script>
</head>
<body>
<noscript>
<img src="https://stats.data.gouv.fr/matomo.php?idsite=196&amp;rec=1" style="border:0" alt="" />
</noscript>
</body>
<head>
<meta charset="utf-8" />
<title>Ecobalyse</title>
<link rel="canonical" href="https://ecobalyse.beta.gouv.fr/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Accélerer la mise en place de l'affichage environnemental" />
<meta name="theme-color" content="#333333" />
<link rel="icon" type="image/svg" href="./img/logo.svg" />
<link href="./public/icomoon/style.css" rel="stylesheet" />
<link href="./styles.scss" rel="stylesheet" />
<script src="./public/build/main.js"></script>
<script type="module" src="./index.js"></script>
</head>
<body>
<noscript>
<img
src="https://stats.data.gouv.fr/matomo.php?idsite=196&amp;rec=1"
style="border: 0"
alt=""
/>
</noscript>
</body>
</html>
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import "rapidoc";
import { Elm } from "./src/Main.elm";
import * as Sentry from "@sentry/browser";
import { BrowserTracing } from "@sentry/tracing";
import Charts from "./lib/charts";

// Sentry
if (process.env.SENTRY_DSN) {
if (import.meta.env.VITE_SENTRY_DSN) {
Sentry.init({
dsn: process.env.SENTRY_DSN,
dsn: import.meta.env.VITE_SENTRY_DSN,
integrations: [new BrowserTracing()],
tracesSampleRate: 0,
allowUrls: [
Expand All @@ -25,7 +24,7 @@ if (process.env.SENTRY_DSN) {
// The localStorage key to use to store serialized session data
const storeKey = "store";

const app = Elm.Main.init({
const app = window.Elm.Main.init({
flags: {
clientUrl: location.origin + location.pathname,
rawStore: localStorage[storeKey] || "",
Expand Down
Loading