From 452ee3da7fdad5b3d776e07c417dfe84f5b53f19 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Mon, 21 Mar 2022 08:04:59 -0400 Subject: [PATCH 1/2] Move main bundle output to ./dist subfolder Excludes the index.html so that the github page can still work as is. This will declutter the root of the repo a fair bit. --- package.sh | 19 ++++--------------- webpack.config.js | 7 ++++--- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/package.sh b/package.sh index 6d3fc82eb..17cb3b5ac 100755 --- a/package.sh +++ b/package.sh @@ -3,23 +3,12 @@ # Clear out any files remaining from old builds rm -rf .package -mkdir -p .package/dist/src/ThirdParty || true -mkdir -p .package/src/ThirdParty || true -mkdir -p .package/node_modules || true +mkdir -p .package/dist/ || true cp index.html .package +cp favicon.ico .package cp -r electron/* .package -cp -r dist/ext .package/dist -cp -r dist/icons .package/dist -cp -r dist/images .package/dist - -# The js files. -cp dist/vendor.bundle.js .package/dist/vendor.bundle.js -cp main.bundle.js .package/main.bundle.js - -# Source maps -cp dist/vendor.bundle.js.map .package/dist/vendor.bundle.js.map -cp main.bundle.js.map .package/main.bundle.js.map +cp -r dist .package # Install electron sub-dependencies cd electron @@ -28,4 +17,4 @@ cd .. BUILD_PLATFORM="${1:-"all"}" # And finally build the app. -npm run electron:packager-$BUILD_PLATFORM \ No newline at end of file +npm run electron:packager-$BUILD_PLATFORM diff --git a/webpack.config.js b/webpack.config.js index 2bd397aac..487e5a9a1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -63,6 +63,7 @@ module.exports = (env, argv) => { new HtmlWebpackPlugin({ title: "Bitburner", template: "src/index.html", + filename: "../index.html", favicon: "favicon.ico", googleAnalytics: { trackingId: "UA-100157497-1", @@ -136,7 +137,7 @@ module.exports = (env, argv) => { // }, entry: entry, output: { - path: path.resolve(__dirname, "./"), + path: path.resolve(__dirname, outputDirectory), filename: "[name].bundle.js", }, module: { @@ -161,7 +162,7 @@ module.exports = (env, argv) => { loader: "file-loader", options: { name: "[contenthash].[ext]", - outputPath: "dist/images", + outputPath: "images", }, }, ], @@ -184,7 +185,7 @@ module.exports = (env, argv) => { cacheGroups: { vendor: { test: /[\\/]node_modules[\\/]/, - name: `${outputDirectory}/vendor`, + name: `vendor`, chunks: "all", }, }, From cec5f1ce2915f3f851764b77f9bfe75fe3896a27 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Wed, 23 Mar 2022 06:17:50 -0400 Subject: [PATCH 2/2] Move electron build script to /tools/ Also enables bash strict mode flags for the build script --- package.json | 2 +- package.sh => tools/package-electron.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename package.sh => tools/package-electron.sh (94%) mode change 100755 => 100644 diff --git a/package.json b/package.json index 542f511e7..b6a404004 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "test:watch": "jest --watch", "watch": "webpack --watch --mode production", "watch:dev": "webpack --watch --mode development", - "electron": "sh ./package.sh", + "electron": "sh ./tools/package-electron.sh", "electron:packager": "electron-packager .package bitburner --all --out .build --overwrite --icon .package/icon.png --no-prune", "electron:packager-all": "electron-packager .package bitburner --all --out .build --overwrite --icon .package/icon.png", "electron:packager-win": "electron-packager .package bitburner --platform win32 --arch x64 --out .build --overwrite --icon .package/icon.png", diff --git a/package.sh b/tools/package-electron.sh old mode 100755 new mode 100644 similarity index 94% rename from package.sh rename to tools/package-electron.sh index 17cb3b5ac..c0520993f --- a/package.sh +++ b/tools/package-electron.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -euxo pipefail + # Clear out any files remaining from old builds rm -rf .package