Skip to content

Commit

Permalink
feat: copy used emoji svgs
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Setch <[email protected]>
  • Loading branch information
setchy committed Oct 10, 2024
1 parent 230d727 commit 7fb913e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/webpack.config.renderer.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { merge } from 'webpack-merge';
import baseConfig from './webpack.config.common';
import webpackPaths from './webpack.paths';

import { EMOJI_CODE_POINTS } from '../src/renderer/utils/emojis';

const configuration: webpack.Configuration = {
devtool: 'inline-source-map',

Expand Down Expand Up @@ -72,6 +74,12 @@ const configuration: webpack.Configuration = {
'svg',
),
to: 'images/twemoji',
// Only copy the SVGs for the emojis we use
filter: (resourcePath) => {
return EMOJI_CODE_POINTS.some((svg) =>
resourcePath.endsWith(`/${svg}.svg`),
);
},
},
],
}),
Expand Down
26 changes: 26 additions & 0 deletions src/renderer/utils/__snapshots__/emojis.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/renderer/utils/emojis.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { EMOJI_CODE_POINTS } from './emojis';

describe('renderer/utils/emojis.ts', () => {
it('emoji code points', () => {
expect(EMOJI_CODE_POINTS).toHaveLength(20);
expect(EMOJI_CODE_POINTS).toMatchSnapshot();
});
});
16 changes: 16 additions & 0 deletions src/renderer/utils/emojis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import twemoji from '@discordapp/twemoji';
import { Constants } from './constants';
import { Errors } from './errors';

const ALL_EMOJIS = [
...Constants.ALL_READ_EMOJIS,
...Errors.BAD_CREDENTIALS.emojis,
...Errors.MISSING_SCOPES.emojis,
...Errors.NETWORK.emojis,
...Errors.RATE_LIMITED.emojis,
...Errors.UNKNOWN.emojis,
];

export const EMOJI_CODE_POINTS = ALL_EMOJIS.map((emoji) =>
twemoji.convert.toCodePoint(emoji),
);

0 comments on commit 7fb913e

Please sign in to comment.