Skip to content

feat: copy used emoji svgs #1580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2024
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),
);