From b2b38d4cf3b2438cdf67669285a12643da4ef032 Mon Sep 17 00:00:00 2001 From: Wout De Puysseleir Date: Mon, 10 Apr 2023 12:04:15 -0700 Subject: [PATCH] Improve build.js --- assets/copy/build.js | 36 ++++----------------- example_project/assets/build.js | 41 ++++-------------------- example_project/assets/package-lock.json | 2 +- package-lock.json | 4 +-- 4 files changed, 17 insertions(+), 66 deletions(-) diff --git a/assets/copy/build.js b/assets/copy/build.js index 5c813dc..9303600 100644 --- a/assets/copy/build.js +++ b/assets/copy/build.js @@ -15,6 +15,9 @@ let optsClient = { target: "es2017", outdir: "../priv/static/assets", logLevel: "info", + minify: deploy, + sourcemap: watch ? "inline" : false, + watch, plugins: [ importGlobPlugin(), sveltePlugin({ @@ -34,6 +37,8 @@ let optsServer = { target: "node19.6.1", outdir: "../priv/static/assets/server", logLevel: "info", + sourcemap: watch ? "inline" : false, + watch, plugins: [ importGlobPlugin(), sveltePlugin({ @@ -43,44 +48,17 @@ let optsServer = { ], } -if (watch) { - optsClient = { - ...optsClient, - watch, - sourcemap: "inline", - } - - optsServer = { - ...optsServer, - watch, - sourcemap: "inline", - } -} - -if (deploy) { - optsClient = { - ...optsClient, - minify: true, - } -} - const client = esbuild.build(optsClient) const server = esbuild.build(optsServer) if (watch) { client.then(_result => { - process.stdin.on("close", () => { - process.exit(0) - }) - + process.stdin.on("close", () => process.exit(0)) process.stdin.resume() }) server.then(_result => { - process.stdin.on("close", () => { - process.exit(0) - }) - + process.stdin.on("close", () => process.exit(0)) process.stdin.resume() }) } diff --git a/example_project/assets/build.js b/example_project/assets/build.js index 945ca04..9303600 100644 --- a/example_project/assets/build.js +++ b/example_project/assets/build.js @@ -15,6 +15,9 @@ let optsClient = { target: "es2017", outdir: "../priv/static/assets", logLevel: "info", + minify: deploy, + sourcemap: watch ? "inline" : false, + watch, plugins: [ importGlobPlugin(), sveltePlugin({ @@ -34,6 +37,8 @@ let optsServer = { target: "node19.6.1", outdir: "../priv/static/assets/server", logLevel: "info", + sourcemap: watch ? "inline" : false, + watch, plugins: [ importGlobPlugin(), sveltePlugin({ @@ -43,49 +48,17 @@ let optsServer = { ], } -if (watch) { - optsClient = { - ...optsClient, - watch, - sourcemap: "inline", - } - - optsServer = { - ...optsServer, - watch, - sourcemap: "inline", - } -} - -if (deploy) { - optsClient = { - ...optsClient, - minify: true, - } - - optsServer = { - ...optsServer, - minify: true, - } -} - const client = esbuild.build(optsClient) const server = esbuild.build(optsServer) if (watch) { client.then(_result => { - process.stdin.on("close", () => { - process.exit(0) - }) - + process.stdin.on("close", () => process.exit(0)) process.stdin.resume() }) server.then(_result => { - process.stdin.on("close", () => { - process.exit(0) - }) - + process.stdin.on("close", () => process.exit(0)) process.stdin.resume() }) } diff --git a/example_project/assets/package-lock.json b/example_project/assets/package-lock.json index 001f6cf..d2c198d 100644 --- a/example_project/assets/package-lock.json +++ b/example_project/assets/package-lock.json @@ -21,7 +21,7 @@ }, "..": {}, "../..": { - "version": "0.3.5", + "version": "0.4.0", "license": "MIT", "devDependencies": { "prettier": "2.8.7", diff --git a/package-lock.json b/package-lock.json index 8363ab1..324e8c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "live_svelte", - "version": "0.3.5", + "version": "0.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "live_svelte", - "version": "0.3.5", + "version": "0.4.0", "license": "MIT", "devDependencies": { "prettier": "2.8.7",