Skip to content

Commit 23724b7

Browse files
committed
Add information about nonprod app icon to README
1 parent 6695d3b commit 23724b7

File tree

8 files changed

+38
-6
lines changed

8 files changed

+38
-6
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ VITE_WEBSITE_URL=https://coteh.github.io/2048-clone/
77
# Sentry
88
SENTRY_AUTH_TOKEN=
99

10-
# Deployment environment, can be DEV, leave blank for production
11-
DEPLOY_ENV=
10+
# Deployment environment, (e.g. DEV) leave blank for production
11+
DEPLOY_ENV=LOCAL

.gitignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,14 @@ ssl/
2424
# Misc
2525
.DS_Store
2626

27-
# Icons
28-
/dist/icons
27+
# Ignore everything in the dist directory
28+
dist/**
29+
30+
# Allow access to the icons directory
31+
!dist/icons/
32+
33+
# Ignore everything in the icons directory
34+
dist/icons/*
35+
36+
# Allow specific icon files
37+
!dist/icons/icon*_LOCAL.png

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,27 @@ npm run devs
7777

7878
The game should render when navigating to https://localhost:5173.
7979

80+
### Optional Components
81+
82+
#### Nonprod App Icon
83+
84+
With [ImageMagick](https://imagemagick.org/) installed, both the build script and the dev server are capable of generating a version of the app icon with a label (e.g., "LOCAL", "DEV") at the bottom. This helps distinguish the local version of the app from the production build when saving it to the home screen.
85+
86+
![prod app icon](public/icon128.png)
87+
![local app icon](dist/icons/icon128_LOCAL.png)
88+
89+
For systems without ImageMagick, the pregenerated version of the icon in the repo is used.
90+
91+
To generate icons with different labels, set the `DEPLOY_ENV` environment variable to the desired label before running the build script or the dev server.
92+
93+
Example:
94+
```sh
95+
# Deployment environment, (e.g. DEV) leave blank for production
96+
DEPLOY_ENV=DEV
97+
```
98+
99+
In this example, the build script will use `DEPLOY_ENV` to create icons with the "DEV" label.
100+
80101
## Testing
81102

82103
Run the following to launch unit tests:

dist/icons/icon128_LOCAL.png

7.68 KB
Loading

dist/icons/icon128_classic_LOCAL.png

9.14 KB
Loading

dist/icons/icon152_LOCAL.png

9.76 KB
Loading

dist/icons/icon152_classic_LOCAL.png

11.5 KB
Loading

plugins/app-labels.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ interface PluginOptions {
2121
position: "top" | "bottom" | { x: number; y: number };
2222
}
2323

24+
const MAGICK_COMMAND = "magick";
25+
2426
// TODO: Support other filetypes besides PNG
2527
export default function appIconLabel(options: PluginOptions) {
2628
const { source, output, environment, icons, position } = options;
2729
const buildDir = path.resolve(process.cwd(), "build");
2830

2931
const buildIcons = (env: string) => {
3032
try {
31-
childProcess.execSync("magick -version", { stdio: "ignore" });
33+
childProcess.execSync(`${MAGICK_COMMAND} -version`, { stdio: "ignore" });
3234
} catch (e) {
3335
console.warn("ImageMagick is not installed. Skipping icon labeling.");
3436
return;
@@ -51,7 +53,7 @@ export default function appIconLabel(options: PluginOptions) {
5153
: "+0-10"
5254
: `+${position.x}+${position.y}`;
5355

54-
const cmd = `magick ${srcPath} -strip -gravity south -fill "${font.color}" -undercolor "#000000AA" -pointsize ${font.size} -font ${font.family} -annotate ${positionOption} "${env}" ${destPath}`;
56+
const cmd = `${MAGICK_COMMAND} ${srcPath} -strip -gravity south -fill "${font.color}" -undercolor "#000000AA" -pointsize ${font.size} -font ${font.family} -annotate ${positionOption} "${env}" ${destPath}`;
5557
try {
5658
childProcess.execSync(cmd);
5759
console.log(`Processed ${name} -> ${path.basename(destPath)}`);

0 commit comments

Comments
 (0)