Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
);