-
Notifications
You must be signed in to change notification settings - Fork 279
refactor: major project structure update #1564
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
Changes from 12 commits
d16c501
5eeed57
56e46d3
877635e
4fb5405
964db86
26448b2
a067147
3959bd7
66ef544
01a1eed
67d56b5
39771f0
ea50d6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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; |
| 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); |
| 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', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤷♂️ - was just following the erb template
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| mode: 'production', | ||
|
|
||
| optimization: { | ||
| minimize: true, | ||
| minimizer: [new TerserPlugin()], | ||
| }, | ||
| }; | ||
|
|
||
| export default merge(baseConfig, configuration); | ||
| 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); |
| 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); |
| 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, | ||
| }; |
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.
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.
Good eyes re: 2 - that's an oversight on my part. Updated
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.
re 1 - it was within the https://github.com/electron-react-boilerplate/electron-react-boilerplate example. My assumption that they remove the source maps so that the packaged+minified code cannot be reconstructed. Not a big deal for an open source project
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.
Exactly, and it may help with tracing back bugs reported by users, however I am not sure how we can help users provide these off the top of my head 🤔
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.
Yeah, not too sure. I think our exception handling and electron-logger should be catching most user reported issues.
That said, would it be best for now to skip minimizing source code?