Update build process

`npm run build` now generates a .app folder with the minimal run files
`npm run electron` now uses the .app contents as a base
deploy-dev.yml should upload just the .app folder after building (not tested yet)
This commit is contained in:
omuretsu 2023-01-10 20:51:14 -05:00
parent f266906f6f
commit 41451280ab
5 changed files with 22 additions and 11 deletions

@ -29,7 +29,7 @@ jobs:
- run: npm run build - run: npm run build
- uses: actions/upload-pages-artifact@v1 - uses: actions/upload-pages-artifact@v1
with: with:
path: "." path: ".app"
- name: Deploy to gh pages - name: Deploy to gh pages
id: deployment id: deployment
uses: actions/deploy-pages@v1 uses: actions/deploy-pages@v1

3
.gitignore vendored

@ -12,7 +12,8 @@ Netburner.txt
/input/bitburner.api.json /input/bitburner.api.json
.cypress .cypress
# tmp folder for electron # tmp folder for build and electron
.app
.package .package
.build .build

@ -105,7 +105,7 @@
"format:report-diff": "bash -c 'if [[ $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | wc -c) -ne 0 ]]; then prettier -c $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | xargs); fi'", "format:report-diff": "bash -c 'if [[ $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | wc -c) -ne 0 ]]; then prettier -c $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | xargs); fi'",
"start": "http-server -p 8000", "start": "http-server -p 8000",
"start:dev": "webpack serve --progress --env devServer --mode development", "start:dev": "webpack serve --progress --env devServer --mode development",
"build": "webpack --mode production", "build": "bash ./tools/build.sh",
"build:dev": "webpack --mode development", "build:dev": "webpack --mode development",
"lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src", "lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src",
"lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 src", "lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 src",

13
tools/build.sh Normal file

@ -0,0 +1,13 @@
#!/bin/bash
# builds the game in the root folder
webpack --mode production
# Clear out any files remaining from old builds and recreate folder
rm -rf .app
mkdir .app
# Should be all the files needed.
cp index.html .app
cp favicon.ico .app
cp -r dist .app

@ -1,18 +1,15 @@
#!/bin/bash #!/bin/bash
set -euxo pipefail # Clear out any files remaining from old builds and recreate folder
# Clear out any files remaining from old builds
rm -rf .package rm -rf .package
mkdir .package
mkdir -p .package/dist/ || true # .app should have the fully built game already after npm run build
cp -r .app/* .package
cp index.html .package
cp favicon.ico .package
cp -r electron/* .package cp -r electron/* .package
# steam_appid.txt would end up in the resource dir # steam_appid.txt would end up in the resource dir
rm .package/steam_appid.txt rm .package/steam_appid.txt
cp -r dist .package
# Install electron sub-dependencies # Install electron sub-dependencies
cd electron cd electron