-
Notifications
You must be signed in to change notification settings - Fork 258
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
refactor: major project structure update #1564
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d16c501
refactor: split code into main and renderer modules, adopt TS for mai…
setchy 5eeed57
refactor: split code into main and renderer modules, adopt TS for mai…
setchy 56e46d3
refactor: split code into main and renderer modules, adopt TS for mai…
setchy 877635e
refactor: split code into main and renderer modules, adopt TS for mai…
setchy 4fb5405
refactor: split code into main and renderer modules, adopt TS for mai…
setchy 964db86
refactor: split code into main and renderer modules, adopt TS for mai…
setchy 26448b2
refactor: split code into main and renderer modules, adopt TS for mai…
setchy a067147
build: universal only
setchy 3959bd7
refactor: split code into main and renderer modules, adopt TS for mai…
setchy 66ef544
build: remove resize polyfill dep
setchy 01a1eed
build: macos dist
setchy 67d56b5
build: macos dist
setchy 39771f0
build: fix order of source maps
setchy ea50d6a
Merge branch 'main' into refactor/major-overhaul
setchy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this in the prod one? - I suppose this relates to us deleting them on the build step. We might keep it if we want to, depends on what gets decided in #1564 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♂️ - was just following the erb template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO source-maps make sense if we have a centralized error reporting. That's probably why the template has it. Since we don't have exception tracking, there's nowhere to send the source maps, so I don't think it's necessary.