Skip to content

Commit 2f0dc88

Browse files
authored
feat: copy used emoji svgs (#1580)
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent 230d727 commit 2f0dc88

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

config/webpack.config.renderer.base.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { merge } from 'webpack-merge';
77
import baseConfig from './webpack.config.common';
88
import webpackPaths from './webpack.paths';
99

10+
import { EMOJI_CODE_POINTS } from '../src/renderer/utils/emojis';
11+
1012
const configuration: webpack.Configuration = {
1113
devtool: 'inline-source-map',
1214

@@ -72,6 +74,12 @@ const configuration: webpack.Configuration = {
7274
'svg',
7375
),
7476
to: 'images/twemoji',
77+
// Only copy the SVGs for the emojis we use
78+
filter: (resourcePath) => {
79+
return EMOJI_CODE_POINTS.some((svg) =>
80+
resourcePath.endsWith(`/${svg}.svg`),
81+
);
82+
},
7583
},
7684
],
7785
}),

src/renderer/utils/__snapshots__/emojis.test.ts.snap

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/utils/emojis.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { EMOJI_CODE_POINTS } from './emojis';
2+
3+
describe('renderer/utils/emojis.ts', () => {
4+
it('emoji code points', () => {
5+
expect(EMOJI_CODE_POINTS).toHaveLength(20);
6+
expect(EMOJI_CODE_POINTS).toMatchSnapshot();
7+
});
8+
});

src/renderer/utils/emojis.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import twemoji from '@discordapp/twemoji';
2+
import { Constants } from './constants';
3+
import { Errors } from './errors';
4+
5+
const ALL_EMOJIS = [
6+
...Constants.ALL_READ_EMOJIS,
7+
...Errors.BAD_CREDENTIALS.emojis,
8+
...Errors.MISSING_SCOPES.emojis,
9+
...Errors.NETWORK.emojis,
10+
...Errors.RATE_LIMITED.emojis,
11+
...Errors.UNKNOWN.emojis,
12+
];
13+
14+
export const EMOJI_CODE_POINTS = ALL_EMOJIS.map((emoji) =>
15+
twemoji.convert.toCodePoint(emoji),
16+
);

0 commit comments

Comments
 (0)