From e71ae91e2c71cd0e00a6589dc66712de1dbe8492 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 15 Jan 2024 01:54:09 +0100 Subject: [PATCH] Tooling: add HTTPS-mode development hosting for debugging on Android --- package-lock.json | 24 ++++++++++++++++++++++-- package.json | 4 +++- vite.config.js | 10 ++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 853d7611f..92b0f86d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mapcomplete", - "version": "0.36.11", + "version": "0.36.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mapcomplete", - "version": "0.36.11", + "version": "0.36.12", "license": "GPL-3.0-or-later", "dependencies": { "@rgossiaux/svelte-headlessui": "^1.0.2", @@ -83,6 +83,7 @@ "@types/xml2js": "^0.4.9", "@typescript-eslint/eslint-plugin": "^6.1.0", "@typescript-eslint/parser": "^6.1.0", + "@vitejs/plugin-basic-ssl": "^1.0.2", "assert": "^2.0.0", "chai": "^4.3.6", "dependency-cruiser": "^10.4.0", @@ -4608,6 +4609,18 @@ "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==" }, + "node_modules/@vitejs/plugin-basic-ssl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.0.2.tgz", + "integrity": "sha512-DKHKVtpI+eA5fvObVgQ3QtTGU70CcCnedalzqmGSR050AzKZMdUzgC8KmlOneHWH8dF2hJ3wkC9+8FDVAaDRCw==", + "dev": true, + "engines": { + "node": ">=14.6.0" + }, + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0" + } + }, "node_modules/@vitest/expect": { "version": "0.28.3", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.28.3.tgz", @@ -17096,6 +17109,13 @@ "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==" }, + "@vitejs/plugin-basic-ssl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.0.2.tgz", + "integrity": "sha512-DKHKVtpI+eA5fvObVgQ3QtTGU70CcCnedalzqmGSR050AzKZMdUzgC8KmlOneHWH8dF2hJ3wkC9+8FDVAaDRCw==", + "dev": true, + "requires": {} + }, "@vitest/expect": { "version": "0.28.3", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.28.3.tgz", diff --git a/package.json b/package.json index b7205a434..2205c0ff2 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,9 @@ }, "scripts": { "start": "npm run generate:layeroverview && npm run strt", + "#strt:https": "Start in HTTPS mode. Makes a few things a bit harder, but allows to debug on Android with logging in", + "strt:https": "vite --host | sed 's/localhost:/127.0.0.1:/g'", "strt": "vite --host | sed 's/localhost:/127.0.0.1:/g'", - "strttest": "export NODE_OPTIONS=--max_old_space_size=8364 && parcel serve test.html assets/templates/*.svg assets/templates/fonts/*.ttf", "watch:css": "tailwindcss -i src/index.css -o public/css/index-tailwind-output.css --watch", "generate:css": "tailwindcss -i src/index.css -o public/css/index-tailwind-output.css", "generate:doctests": "doctest-ts-improved . --ignore .*.spec.ts --ignore .*ConfigJson.ts", @@ -179,6 +180,7 @@ "@types/xml2js": "^0.4.9", "@typescript-eslint/eslint-plugin": "^6.1.0", "@typescript-eslint/parser": "^6.1.0", + "@vitejs/plugin-basic-ssl": "^1.0.2", "assert": "^2.0.0", "chai": "^4.3.6", "dependency-cruiser": "^10.4.0", diff --git a/vite.config.js b/vite.config.js index 4c710a8f6..f85973a7e 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,6 +1,7 @@ import { defineConfig } from "vite" import { svelte } from "@sveltejs/vite-plugin-svelte" import fs from "fs" +import basicSsl from '@vitejs/plugin-basic-ssl' const allHtmlFiles = fs.readdirSync(".").filter((f) => f.endsWith(".html")) const input = {} @@ -10,7 +11,12 @@ for (const html of allHtmlFiles) { const name = html.substring(0, html.length - 5) input[name] = "./" + html } - +console.log("Args:",process.argv) +const plugins = [svelte() ] +if(process.argv.indexOf("--https") >= 0){ + console.log("Adding basicSSL") + plugins.push(basicSsl()) +} export default defineConfig({ build: { rollupOptions: { @@ -18,7 +24,7 @@ export default defineConfig({ }, }, base: `${ASSET_URL}`, - plugins: [svelte()], + plugins , server: { port: 1234, },