|
| 1 | +import path from 'node:path'; |
| 2 | +import CopyWebpackPlugin from 'copy-webpack-plugin'; |
| 3 | +import HtmlWebpackPlugin from 'html-webpack-plugin'; |
| 4 | +import MiniCssExtractPlugin from 'mini-css-extract-plugin'; |
| 5 | +import webpack from 'webpack'; |
| 6 | +import { merge } from 'webpack-merge'; |
| 7 | +import baseConfig from './webpack.config.common'; |
| 8 | +import webpackPaths from './webpack.paths'; |
| 9 | + |
| 10 | +const configuration: webpack.Configuration = { |
| 11 | + devtool: 'inline-source-map', |
| 12 | + |
| 13 | + mode: 'development', |
| 14 | + |
| 15 | + target: 'electron-renderer', |
| 16 | + |
| 17 | + entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')], |
| 18 | + |
| 19 | + output: { |
| 20 | + path: webpackPaths.buildPath, |
| 21 | + filename: 'renderer.js', |
| 22 | + library: { |
| 23 | + type: 'umd', |
| 24 | + }, |
| 25 | + }, |
| 26 | + |
| 27 | + module: { |
| 28 | + rules: [ |
| 29 | + { |
| 30 | + test: /\.css$/, |
| 31 | + use: [ |
| 32 | + MiniCssExtractPlugin.loader, // Extract CSS into a separate file |
| 33 | + 'css-loader', // Translates CSS into CommonJS |
| 34 | + 'postcss-loader', // Automatically uses the postcss.config.js file |
| 35 | + ], |
| 36 | + }, |
| 37 | + ], |
| 38 | + }, |
| 39 | + |
| 40 | + plugins: [ |
| 41 | + // Development Keys - See README.md |
| 42 | + new webpack.EnvironmentPlugin({ |
| 43 | + OAUTH_CLIENT_ID: '3fef4433a29c6ad8f22c', |
| 44 | + OAUTH_CLIENT_SECRET: '9670de733096c15322183ff17ed0fc8704050379', |
| 45 | + }), |
| 46 | + |
| 47 | + // Extract CSS into a separate file |
| 48 | + new MiniCssExtractPlugin({ |
| 49 | + filename: 'styles.css', // Output file for the CSS |
| 50 | + }), |
| 51 | + |
| 52 | + // Generate HTML file with script and link tags injected |
| 53 | + new HtmlWebpackPlugin({ |
| 54 | + filename: path.join('index.html'), |
| 55 | + template: path.join(webpackPaths.srcRendererPath, 'index.html'), |
| 56 | + minify: { |
| 57 | + collapseWhitespace: true, |
| 58 | + removeAttributeQuotes: true, |
| 59 | + removeComments: true, |
| 60 | + }, |
| 61 | + isBrowser: false, |
| 62 | + }), |
| 63 | + |
| 64 | + // Twemoji SVGs for Emoji parsing |
| 65 | + new CopyWebpackPlugin({ |
| 66 | + patterns: [ |
| 67 | + { |
| 68 | + from: path.join( |
| 69 | + webpackPaths.nodeModulesPath, |
| 70 | + '@discordapp/twemoji', |
| 71 | + 'dist', |
| 72 | + 'svg', |
| 73 | + ), |
| 74 | + to: 'images/twemoji', |
| 75 | + }, |
| 76 | + ], |
| 77 | + }), |
| 78 | + ], |
| 79 | +}; |
| 80 | + |
| 81 | +export default merge(baseConfig, configuration); |
0 commit comments