Add local serving and launch configurations

This commit is contained in:
JannisX11 2025-03-02 22:23:58 +01:00
parent 56d6cbfa52
commit 6cd7dc7ce8
6 changed files with 51 additions and 22 deletions

31
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,31 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron Dev",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"dev"
],
"skipFiles": [
"<node_internals>/**"
]
},
{
"type": "node",
"request": "launch",
"name": "Local Server",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"serve"
],
"skipFiles": [
"<node_internals>/**"
]
}
]
}

14
.vscode/settings.json vendored
View File

@ -1,13 +1,5 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.tsc.autoDetect": "off",
"json.schemas": [
{
"fileMatch": [
"/*electron-builder.json5",
"/*electron-builder.json"
],
"url": "https://json.schemastore.org/electron-builder"
}
]
"editor.indentSize": "tabSize",
"editor.tabSize": 4,
"editor.insertSpaces": false
}

View File

@ -6,7 +6,8 @@ const pkg = createRequire(import.meta.url)("./package.json");
const options = commandLineArgs([
{name: 'target', type: String},
{name: 'watch', type: Boolean}
{name: 'watch', type: Boolean},
{name: 'serve', type: Boolean},
])
function conditionalImportPlugin(config) {
@ -44,13 +45,20 @@ const config = {
sourcemap: true,
}
if (options.watch) {
async function watch() {
let ctx = await esbuild.context(config);
if (options.watch || options.serve) {
let ctx = await esbuild.context(config);
if (isApp) {
await ctx.watch({});
console.log('Watching files')
} else {
const host = 'localhost';
const port = 3000;
await ctx.serve({
servedir: import.meta.dirname,
host,
port
});
console.log(`Hosting app at http://${host}:${port}`)
}
watch();
} else {
await esbuild.build(config);
}

View File

@ -116,10 +116,10 @@
},
"scripts": {
"dev": "concurrently --raw \"electron .\" \"node ./build.js --target=electron --watch\"",
"dev-web": "node ./build.js --target=web --serve",
"serve": "node ./build.js --target=web --serve",
"build-web": "node ./build.js --target=web",
"build-electron": "node ./build.js --target=electron",
"build-beta": "npm run build-electron && electron-builder --windows portable",
"build-test-portable": "npm run build-electron && electron-builder --windows portable",
"publish-windows": "npm run build-electron && electron-builder -w --publish=onTagOrDraft && node ./scripts/rename_portable.js && electron-builder --windows portable --publish=onTagOrDraft",
"pwa": "node ./scripts/generate_pwa.js",
"prepublish": "npm run build-web && npm run pwa",

View File

@ -1,7 +1,6 @@
{
"include": [
"js/**/*",
"types/**/*"
"js/**/*"
],
"compilerOptions": {
"target": "ES6",

View File

@ -1 +0,0 @@
/// <reference types="blockbench-types" />