-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: major project structure update (#1564)
* refactor: split code into main and renderer modules, adopt TS for main, and improve webpack process for bundling Signed-off-by: Adam Setch <[email protected]> * refactor: split code into main and renderer modules, adopt TS for main, and improve webpack process for bundling Signed-off-by: Adam Setch <[email protected]> * refactor: split code into main and renderer modules, adopt TS for main, and improve webpack process for bundling Signed-off-by: Adam Setch <[email protected]> * refactor: split code into main and renderer modules, adopt TS for main, and improve webpack process for bundling Signed-off-by: Adam Setch <[email protected]> * refactor: split code into main and renderer modules, adopt TS for main, and improve webpack process for bundling Signed-off-by: Adam Setch <[email protected]> * refactor: split code into main and renderer modules, adopt TS for main, and improve webpack process for bundling Signed-off-by: Adam Setch <[email protected]> * refactor: split code into main and renderer modules, adopt TS for main, and improve webpack process for bundling Signed-off-by: Adam Setch <[email protected]> * build: universal only Signed-off-by: Adam Setch <[email protected]> * refactor: split code into main and renderer modules, adopt TS for main, and improve webpack process for bundling Signed-off-by: Adam Setch <[email protected]> * build: remove resize polyfill dep Signed-off-by: Adam Setch <[email protected]> * build: macos dist Signed-off-by: Adam Setch <[email protected]> * build: macos dist Signed-off-by: Adam Setch <[email protected]> * build: fix order of source maps Signed-off-by: Adam Setch <[email protected]> --------- Signed-off-by: Adam Setch <[email protected]>
- Loading branch information
Showing
203 changed files
with
2,047 additions
and
887 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Settings as per electron-builder note: https://www.electron.build/index.html#note-for-pnpm | ||
node-linker=hoisted | ||
shamefully-hoist=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type webpack from 'webpack'; | ||
|
||
const configuration: webpack.Configuration = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(js|ts|tsx)?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
|
||
resolve: { | ||
extensions: ['.tsx', '.ts', '.js'], | ||
}, | ||
|
||
node: { | ||
__dirname: false, | ||
__filename: false, | ||
}, | ||
}; | ||
|
||
export default configuration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import path from 'node:path'; | ||
import type webpack from 'webpack'; | ||
import { merge } from 'webpack-merge'; | ||
import baseConfig from './webpack.config.common'; | ||
import webpackPaths from './webpack.paths'; | ||
|
||
const configuration: webpack.Configuration = { | ||
devtool: 'inline-source-map', | ||
|
||
mode: 'development', | ||
|
||
target: 'electron-main', | ||
|
||
entry: [path.join(webpackPaths.srcMainPath, 'main.ts')], | ||
|
||
output: { | ||
path: webpackPaths.buildPath, | ||
filename: 'main.js', | ||
library: { | ||
type: 'umd', | ||
}, | ||
}, | ||
}; | ||
|
||
export default merge(baseConfig, configuration); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import TerserPlugin from 'terser-webpack-plugin'; | ||
import type webpack from 'webpack'; | ||
import { merge } from 'webpack-merge'; | ||
import baseConfig from './webpack.config.main.base'; | ||
|
||
const configuration: webpack.Configuration = { | ||
devtool: 'source-map', | ||
|
||
mode: 'production', | ||
|
||
optimization: { | ||
minimize: true, | ||
minimizer: [new TerserPlugin()], | ||
}, | ||
}; | ||
|
||
export default merge(baseConfig, configuration); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import path from 'node:path'; | ||
import CopyWebpackPlugin from 'copy-webpack-plugin'; | ||
import HtmlWebpackPlugin from 'html-webpack-plugin'; | ||
import MiniCssExtractPlugin from 'mini-css-extract-plugin'; | ||
import webpack from 'webpack'; | ||
import { merge } from 'webpack-merge'; | ||
import baseConfig from './webpack.config.common'; | ||
import webpackPaths from './webpack.paths'; | ||
|
||
const configuration: webpack.Configuration = { | ||
devtool: 'inline-source-map', | ||
|
||
mode: 'development', | ||
|
||
target: 'electron-renderer', | ||
|
||
entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')], | ||
|
||
output: { | ||
path: webpackPaths.buildPath, | ||
filename: 'renderer.js', | ||
library: { | ||
type: 'umd', | ||
}, | ||
}, | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
MiniCssExtractPlugin.loader, // Extract CSS into a separate file | ||
'css-loader', // Translates CSS into CommonJS | ||
'postcss-loader', // Automatically uses the postcss.config.js file | ||
], | ||
}, | ||
], | ||
}, | ||
|
||
plugins: [ | ||
// Development Keys - See README.md | ||
new webpack.EnvironmentPlugin({ | ||
OAUTH_CLIENT_ID: '3fef4433a29c6ad8f22c', | ||
OAUTH_CLIENT_SECRET: '9670de733096c15322183ff17ed0fc8704050379', | ||
}), | ||
|
||
// Extract CSS into a separate file | ||
new MiniCssExtractPlugin({ | ||
filename: 'styles.css', // Output file for the CSS | ||
}), | ||
|
||
// Generate HTML file with script and link tags injected | ||
new HtmlWebpackPlugin({ | ||
filename: path.join('index.html'), | ||
template: path.join(webpackPaths.srcRendererPath, 'index.html'), | ||
minify: { | ||
collapseWhitespace: true, | ||
removeAttributeQuotes: true, | ||
removeComments: true, | ||
}, | ||
isBrowser: false, | ||
}), | ||
|
||
// Twemoji SVGs for Emoji parsing | ||
new CopyWebpackPlugin({ | ||
patterns: [ | ||
{ | ||
from: path.join( | ||
webpackPaths.nodeModulesPath, | ||
'@discordapp/twemoji', | ||
'dist', | ||
'svg', | ||
), | ||
to: 'images/twemoji', | ||
}, | ||
], | ||
}), | ||
], | ||
}; | ||
|
||
export default merge(baseConfig, configuration); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'; | ||
import TerserPlugin from 'terser-webpack-plugin'; | ||
import type webpack from 'webpack'; | ||
import { merge } from 'webpack-merge'; | ||
import baseConfig from './webpack.config.renderer.base'; | ||
|
||
const configuration: webpack.Configuration = { | ||
devtool: 'source-map', | ||
|
||
mode: 'production', | ||
|
||
optimization: { | ||
minimize: true, | ||
minimizer: [new TerserPlugin(), new CssMinimizerPlugin()], | ||
}, | ||
}; | ||
|
||
export default merge(baseConfig, configuration); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import path from 'node:path'; | ||
|
||
const rootPath = path.join(__dirname, '..'); | ||
|
||
const nodeModulesPath = path.join(rootPath, 'node_modules'); | ||
|
||
const srcPath = path.join(rootPath, 'src'); | ||
const srcMainPath = path.join(srcPath, 'main'); | ||
const srcRendererPath = path.join(srcPath, 'renderer'); | ||
|
||
const buildPath = path.join(rootPath, 'build'); | ||
|
||
const distPath = path.join(rootPath, 'dist'); | ||
|
||
export default { | ||
rootPath, | ||
nodeModulesPath, | ||
srcPath, | ||
srcMainPath, | ||
srcRendererPath, | ||
buildPath, | ||
distPath, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.