11import path from 'node:path' ;
22
3+ import twemoji from '@discordapp/twemoji' ;
34import CopyWebpackPlugin from 'copy-webpack-plugin' ;
45import HtmlWebpackPlugin from 'html-webpack-plugin' ;
56import MiniCssExtractPlugin from 'mini-css-extract-plugin' ;
67import webpack from 'webpack' ;
78import { merge } from 'webpack-merge' ;
89
9- import { ALL_EMOJI_SVG_FILENAMES } from '../src/renderer/utils/emojis' ;
10+ import { Constants } from '../src/renderer/constants' ;
11+ import { Errors } from '../src/renderer/utils/errors' ;
1012import baseConfig from './webpack.config.common' ;
1113import webpackPaths from './webpack.paths' ;
1214
15+ const ALL_EMOJIS = [
16+ ...Constants . ALL_READ_EMOJIS ,
17+ ...Errors . BAD_CREDENTIALS . emojis ,
18+ ...Errors . MISSING_SCOPES . emojis ,
19+ ...Errors . NETWORK . emojis ,
20+ ...Errors . RATE_LIMITED . emojis ,
21+ ...Errors . UNKNOWN . emojis ,
22+ ] ;
23+ 24+ export const ALL_EMOJI_SVG_FILENAMES = ALL_EMOJIS . map ( ( emoji ) => {
25+ const imgHtml = twemoji . parse ( emoji , { folder : 'svg' , ext : '.svg' } ) ;
26+ return extractSvgFilename ( imgHtml ) ;
27+ } ) ;
28+ 1329const configuration : webpack . Configuration = {
1430 devtool : 'inline-source-map' ,
1531
1632 mode : 'development' ,
1733
18- target : ' electron-renderer',
34+ target : [ 'web' , ' electron-renderer'] ,
1935
2036 entry : [ path . join ( webpackPaths . srcRendererPath , 'index.tsx' ) ] ,
2137
2238 output : {
2339 path : webpackPaths . buildPath ,
2440 filename : 'renderer.js' ,
25- library : {
26- type : 'umd' ,
27- } ,
2841 } ,
2942
3043 module : {
@@ -61,7 +74,6 @@ const configuration: webpack.Configuration = {
6174 removeAttributeQuotes : true ,
6275 removeComments : true ,
6376 } ,
64- isBrowser : false ,
6577 } ) ,
6678
6779 // Twemoji SVGs for Emoji parsing
@@ -87,4 +99,11 @@ const configuration: webpack.Configuration = {
8799 ] ,
88100} ;
89101
102+ function extractSvgFilename ( imgHtml : string ) {
103+ const srcMatch = / s r c = " ( .* ) " / . exec ( imgHtml ) ;
104+ const src = srcMatch ? srcMatch [ 1 ] : '' ;
105+ const filename = src . split ( '/' ) . pop ( ) ; // Get the last part after splitting by "/"
106+ return filename ;
107+ }
108+ 90109export default merge ( baseConfig , configuration ) ;
0 commit comments