From 0ed1c276ddbe9a5e51f4da2c73b8afec1bdd82c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Tue, 2 Jan 2024 16:15:33 +0000 Subject: [PATCH] chore: made some frontend code optional Using NODE_ENV to determine if frontend code should be included in the build. --- CHANGELOG.md | 2 +- frontends/web/package.json | 7 ++++--- frontends/web/ts/gb.ts | 13 ++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 290c3c3b..2f56da0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -* +* Made part of the frontend code conditional on `NODE_ENV = "development"` ### Fixed diff --git a/frontends/web/package.json b/frontends/web/package.json index 7449e901..915278fa 100644 --- a/frontends/web/package.json +++ b/frontends/web/package.json @@ -8,7 +8,7 @@ }, "license": "Apache-2.0", "scripts": { - "build": "parcel build index.html", + "build": "NODE_ENV=production parcel build index.html", "dev": "parcel index.html", "lint": "eslint .", "nodemon": "nodemon --exec \"parcel --no-cache index.html\"", @@ -19,10 +19,11 @@ "source": "index.ts", "devDependencies": { "@parcel/transformer-typescript-tsc": "^2.10.3", + "@types/node": "^20.10.6", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", - "@typescript-eslint/eslint-plugin": "^6.16.0", - "@typescript-eslint/parser": "^6.16.0", + "@typescript-eslint/eslint-plugin": "^6.17.0", + "@typescript-eslint/parser": "^6.17.0", "buffer": "^6.0.3", "emukit": "^0.9.4", "eslint": "^8.56.0", diff --git a/frontends/web/ts/gb.ts b/frontends/web/ts/gb.ts index a7a5a68e..c37cc617 100644 --- a/frontends/web/ts/gb.ts +++ b/frontends/web/ts/gb.ts @@ -543,17 +543,20 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { } get sections(): SectionInfo[] { - return [ + const _sections: SectionInfo[] = [ { name: "Serial", icon: require("../res/serial.svg"), node: SerialSection({ emulator: this }) - }, - { - name: "Test", - node: TestSection({}) } ]; + if (process.env.NODE_ENV === "development") { + _sections.push({ + name: "Test", + node: TestSection({}) + }); + } + return _sections; } get help(): HelpPanel[] { -- GitLab