1
1
import path from 'node:path' ;
2
2
3
+ import twemoji from '@discordapp/twemoji' ;
3
4
import CopyWebpackPlugin from 'copy-webpack-plugin' ;
4
5
import HtmlWebpackPlugin from 'html-webpack-plugin' ;
5
6
import MiniCssExtractPlugin from 'mini-css-extract-plugin' ;
6
7
import webpack from 'webpack' ;
7
8
import { merge } from 'webpack-merge' ;
8
9
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' ;
10
12
import baseConfig from './webpack.config.common' ;
11
13
import webpackPaths from './webpack.paths' ;
12
14
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
+
13
29
const configuration : webpack . Configuration = {
14
30
devtool : 'inline-source-map' ,
15
31
16
32
mode : 'development' ,
17
33
18
- target : ' electron-renderer',
34
+ target : [ 'web' , ' electron-renderer'] ,
19
35
20
36
entry : [ path . join ( webpackPaths . srcRendererPath , 'index.tsx' ) ] ,
21
37
22
38
output : {
23
39
path : webpackPaths . buildPath ,
24
40
filename : 'renderer.js' ,
25
- library : {
26
- type : 'umd' ,
27
- } ,
28
41
} ,
29
42
30
43
module : {
@@ -61,7 +74,6 @@ const configuration: webpack.Configuration = {
61
74
removeAttributeQuotes : true ,
62
75
removeComments : true ,
63
76
} ,
64
- isBrowser : false ,
65
77
} ) ,
66
78
67
79
// Twemoji SVGs for Emoji parsing
@@ -87,4 +99,11 @@ const configuration: webpack.Configuration = {
87
99
] ,
88
100
} ;
89
101
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
+
90
109
export default merge ( baseConfig , configuration ) ;
0 commit comments