Skip to content

Commit c45311a

Browse files
committed
build: add alt icons to build
1 parent a8ef75b commit c45311a

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

private/build.ts

+23-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/* eslint-disable no-console,@typescript-eslint/no-magic-numbers */
44
import * as fs from 'node:fs';
5+
import {copyFileSync} from 'node:fs';
56
import {spawnSync} from 'node:child_process';
67
import {Command} from 'commander';
78
import chalk from 'chalk';
@@ -12,6 +13,9 @@ const program = new Command();
1213

1314
const BUILD_ALL = 'all';
1415

16+
// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle
17+
const __dirname = new URL('.', import.meta.url).pathname;
18+
1519
const zipFolder = (source: string, dest: string): Promise<void> => {
1620
const archive = archiver('zip', {zlib: {level: 9}});
1721
const stream = fs.createWriteStream(dest);
@@ -54,7 +58,7 @@ const callback = async (platform: string, {environment, watch, zip}) => {
5458
command.push('--watch');
5559
}
5660

57-
return spawnSync('npx', command, {
61+
const viteCommand = spawnSync('npx', command, {
5862
stdio: 'inherit',
5963
cwd: process.cwd(),
6064
env: {
@@ -63,6 +67,24 @@ const callback = async (platform: string, {environment, watch, zip}) => {
6367
PLATFORM: platform,
6468
},
6569
});
70+
71+
/**
72+
* @TODO: find better way to get these icons into the bundle
73+
*/
74+
const ADDITIONAL_ICONS = Object.freeze([
75+
`icon-${platform}-16px-alt.png`,
76+
`icon-${platform}-48px-alt.png`,
77+
`icon-${platform}-128px-alt.png`,
78+
]);
79+
80+
const sourceIconDir = `${__dirname}/../assets/icons/`;
81+
const destIconDir = `${__dirname}/../dist/${buildName}/assets/icons/`;
82+
83+
ADDITIONAL_ICONS.forEach((icon) => {
84+
copyFileSync(`${sourceIconDir}${icon}`, `${destIconDir}${icon}`);
85+
});
86+
87+
return viteCommand;
6688
}),
6789
);
6890

src/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export const CONTENT = 'content';
2222

2323
export const BACKGROUND = 'background';
2424

25-
export const ACTIVE_ICON = `icon-${PLATFORM}-128px-alt.png`;
25+
export const ACTIVE_ICON = `assets/icons/icon-${PLATFORM}-128px-alt.png`;
2626

27-
export const DEFAULT_ICON = `icon-${PLATFORM}-128px.png`;
27+
export const DEFAULT_ICON = `assets/icons/icon-${PLATFORM}-128px.png`;
2828

2929
export const URL_SETTING_PREFIX = `${PLATFORM}-url-setting-`;
3030

0 commit comments

Comments
 (0)