Skip to content

Commit

Permalink
Vite 6 and general cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisl8 committed Dec 28, 2024
1 parent 20007f3 commit bbc036c
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 46 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ server/utilities/version.js
*.tiled-project
*.tiled-session

# Parcel
.parcel-cache

# Playwright
/test-results/
/playwright-report/
Expand Down
18 changes: 2 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Prettier and Eslint are [easy to set up](https://imgs.xkcd.com/comics/will_it_wo

## Deploying Code in Production
### Initial setup
**NOTE: Parcel does pretty much all of its work in RAM, which means that for a site with a lot of assets it can use up a lot of memory just to build the site. If you keep getting "killed" when you run `npm run build` on a low cost virtual host, check how much memory it has. If it is equal to or less than 2GB, you may need to increase it or alternatively [create a swap file](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04) to reliably build (`npm run build`).**
**NOTE: Vite does pretty much all of its work in RAM, which means that for a site with a lot of assets it can use up a lot of memory just to build the site. If you keep getting "killed" when you run `npm run build` on a low cost virtual host, check how much memory it has. If it is equal to or less than 2GB, you may need to increase it or alternatively [create a swap file](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04) to reliably build (`npm run build`).**


The production server must have a recent version of Node.js installed.
Expand Down Expand Up @@ -431,20 +431,6 @@ In some cases, like a narrow hall, or a transition from wide to narrow area, th

TODO: Document more of how to make them work.

## Parcel Notes
Parcel is pretty nice, but it has quirks. Here are my notes.
- [The dist folder is not cleaned between builds](https://github.com/parcel-bundler/parcel/issues/1234)
- This will cause the folder to get very big as it fills with old junk that we deleted.
- Solution: Add `"prebuild": "rm -rf dist",` under the scripts key in `package.json`. Note that this won't work on Windows.
- [How to import audio files](https://github.com/parcel-bundler/parcel/issues/1911#issuecomment-1042854678)
- You must add "url:" to the front of the file name.
- You can see an example of this in `gameLoopAndSceneFactor.js` where the .ogg and .mp3 files are imported.
- [@parcel/transformer-js: Browser scripts cannot have imports or exports.](https://github.com/fregante/browser-extension-template/issues/51#issuecomment-869420069)
- You have to add `type="module"` to all script imports in your .html files
- Example at the bottom of the main `index.html` file where `startGame.js` is imported.
- Other ways to do things
- Of course there are a dozen other ways to do things and a dozen other package managers, but I have been aiming for simplicity in this build, even at the possible expense of build size. It is a game, so one should expect some load time when first visiting the site.

## Favicon Notes
- I used https://www.favicon-generator.org/ to generate the favicon files.
- The source file is `client/src/favicon/bloomby.png`.
Expand All @@ -456,7 +442,7 @@ Parcel is pretty nice, but it has quirks. Here are my notes.
- I put the generated html into `client/index.html`
- Again, I had to edit some parts of it and remove references to things I deleted, so compare the new lines to the existing ones if you update the favicon.
- Technically if you replace the icon images, the file names will stay the same, so you may not have to update `index.html` anyway.
- Parcel bundling will ensure that browser caching sees that the files have changed.
- Vite bundling will ensure that browser caching sees that the files have changed.

## Extruding Tiles
If you don't extrude the tiles, you will get strange lines the game.
Expand Down
20 changes: 1 addition & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,11 @@
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@parcel/packager-raw-url": "^2.12.0",
"@parcel/packager-xml": "^2.12.0",
"@parcel/transformer-webmanifest": "^2.12.0",
"@parcel/transformer-xml": "^2.12.0",
"@playwright/test": "^1.47.2",
"assert": "^2.1.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"eslint": "^9.11.1",
"events": "^3.3.0",
"globals": "^15.10.0",
"parcel": "^2.12.0",
"path-browserify": "^1.0.1",
"pm2": "^5.4.2",
"process": "^0.11.10",
"querystring-es3": "^0.2.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"terser": "^5.37.0",
"url": "^0.11.4",
"util": "^0.12.5",
"vite": "^5.3.1"
"vite": "^6.0.0"
},
"dependencies": {
"bcrypt": "^5.1.1",
Expand Down
2 changes: 0 additions & 2 deletions scripts/pm2DevConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
".idea",
".git",
".gitignore",
".parcel-cache",
"assets",
"dist",
"persistentData",
"client",
"web-dist",
"playwright.config.js",
"tests",
"test-results"
Expand Down
2 changes: 0 additions & 2 deletions src/castSpell.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function castSpell({
owner,
dps = 1,
}) {
/* eslint-disable no-param-reassign */
if (spell === 'writeMessage') {
playerObject.externalDialogOpen = true;
resetMessageDialog();
Expand All @@ -78,7 +77,6 @@ function castSpell({
messageDialog.showModal();
} else {
// Convert text direction to int
// eslint-disable-next-line default-case
switch (direction) {
case 'left':
direction = 180;
Expand Down
4 changes: 0 additions & 4 deletions vite/config.prod.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ const phasermsg = () => {
process.stdout.write(`Building for production...\n`);
},
buildEnd() {
const line = "---------------------------------------------------------";
const msg = `❤️❤️❤️ Tell us about your game! - [email protected] ❤️❤️❤️`;
process.stdout.write(`${line}\n${msg}\n${line}\n`);

process.stdout.write(`✨ Done ✨\n`);
}
}
Expand Down

0 comments on commit bbc036c

Please sign in to comment.