Skip to content

Commit 8b1dd11

Browse files
Refactor code structure for improved readability and maintainability
Refactor webpack configuration files to remove unused variables and improve clarity Update dependencies: upgrade express to 5.1.0, mime to 4.0.7, and node-html-parser to 7.0.1 Update electron-related dependencies to latest versions Update dependencies: upgrade proxy-polyfill to ^0.3.2, react-beautiful-dnd to ^13.1.1, react-datetime-picker to ^7.0.1, and various other packages
1 parent d14c914 commit 8b1dd11

File tree

6 files changed

+5997
-4138
lines changed

6 files changed

+5997
-4138
lines changed

electron/devServer.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const { WEBPACK_ELECTRON_PORT } = require('../config');
33
const chalk = require('chalk');
44
const webpack = require('webpack');
5-
const merge = require('webpack-merge');
5+
const { merge } = require('webpack-merge');
66
const middleware = require('webpack-dev-middleware');
77
const express = require('express');
88
const app = express();
@@ -20,21 +20,18 @@ renderConfig = merge(renderConfig, {
2020
alias: { 'react-dom': '@hot-loader/react-dom' },
2121
symlinks: false,
2222
},
23-
2423
});
2524

2625
const mainCompiler = webpack(mainConfig);
2726
const mainInstance = middleware(mainCompiler, {
28-
logLevel: 'warn',
29-
writeToDisk: filename => {
27+
writeToDisk: (filename) => {
3028
// console.log(`Writing '${filename}'.`);
3129
return true;
3230
},
3331
});
3432

3533
const renderCompiler = webpack(renderConfig);
3634
const renderInstance = middleware(renderCompiler, {
37-
logLevel: 'warn',
3835
publicPath: '/',
3936
});
4037
app.use(require('webpack-hot-middleware')(renderCompiler));
@@ -56,11 +53,11 @@ mainInstance.waitUntilValid(() => {
5653

5754
const child = proc.spawn(electron, ['./dist/electron/webpack/main.js']);
5855

59-
child.stdout.on('data', data => {
56+
child.stdout.on('data', (data) => {
6057
console.log(data.toString());
6158
});
6259

63-
process.on('SIGINT', function() {
60+
process.on('SIGINT', function () {
6461
console.log('Killing threads...');
6562

6663
child.kill('SIGINT');

package.json

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@
4646
"@mui/material": "^5.2.1",
4747
"@ungap/from-entries": "^0.2.1",
4848
"auto-launch": "^5.0.5",
49-
"electron-dl": "^3.2.0",
50-
"electron-log": "^4.4.8",
51-
"electron-notarize": "^1.0.0",
52-
"electron-updater": "^4.2.4",
53-
"express": "^4.17.1",
49+
"electron-dl": "^4.0.0",
50+
"electron-log": "^5.4.3",
51+
"electron-notarize": "^1.2.2",
52+
"electron-updater": "^6.6.2",
53+
"express": "^5.1.0",
5454
"ffmpeg-probe": "^1.0.6",
5555
"humanize-duration": "^3.27.0",
5656
"match-sorter": "^6.3.0",
57-
"mime": "^3.0.0",
58-
"node-html-parser": "^5.1.0",
57+
"mime": "^4.0.7",
58+
"node-html-parser": "^7.0.1",
5959
"parse-duration": "^1.0.0",
60-
"proxy-polyfill": "0.1.6",
60+
"proxy-polyfill": "^0.3.2",
6161
"re-reselect": "^4.0.0",
62-
"react-beautiful-dnd": "^13.1.0",
63-
"react-datetime-picker": "^3.4.3",
62+
"react-beautiful-dnd": "^13.1.1",
63+
"react-datetime-picker": "^7.0.1",
6464
"source-map-explorer": "^2.5.2",
6565
"sudo-prompt": "^9.2.1",
6666
"tempy": "^0.6.0"
@@ -71,6 +71,8 @@
7171
"@babel/plugin-proposal-decorators": "^7.3.0",
7272
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
7373
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
74+
"@babel/plugin-proposal-private-methods": "^7.18.6",
75+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
7476
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
7577
"@babel/plugin-transform-flow-strip-types": "^7.2.3",
7678
"@babel/plugin-transform-runtime": "^7.4.3",
@@ -93,7 +95,7 @@
9395
"@types/three": "^0.103.2",
9496
"adm-zip": "^0.4.13",
9597
"babel-eslint": "^10.0.1",
96-
"babel-loader": "^8.0.5",
98+
"babel-loader": "^9.1.3",
9799
"babel-plugin-add-module-exports": "^1.0.4",
98100
"babel-plugin-import-glob": "^2.0.0",
99101
"babel-plugin-transform-imports": "^1.5.1",
@@ -102,12 +104,12 @@
102104
"classnames": "^2.2.5",
103105
"codemirror": "^5.39.2",
104106
"connected-react-router": "^6.8.0",
105-
"copy-webpack-plugin": "^6.4.1",
107+
"copy-webpack-plugin": "^11.0.0",
106108
"country-data": "^0.0.31",
107109
"cross-env": "^7.0.3",
108110
"crypto-js": "^4.0.0",
109111
"css-doodle": "^0.7.1",
110-
"css-loader": "^2.1.0",
112+
"css-loader": "^6.8.1",
111113
"cssnano": "^4.1.10",
112114
"dat.gui": "^0.7.2",
113115
"decompress": "^4.2.1",
@@ -154,8 +156,9 @@
154156
"node-loader": "^0.6.0",
155157
"node-wget": "^0.4.3",
156158
"nodemon": "^1.19.1",
157-
"postcss-import": "^12.0.1",
158-
"postcss-loader": "^3.0.0",
159+
"postcss": "^8.5.6",
160+
"postcss-import": "^15.1.0",
161+
"postcss-loader": "^7.3.3",
159162
"postcss-rtl": "^1.7.3",
160163
"preprocess-loader": "^0.3.0",
161164
"prettier": "^2.2.1",
@@ -189,31 +192,31 @@
189192
"remark-react": "^8.0.0",
190193
"reselect": "^4.0.0",
191194
"sass": "^1.29.0",
192-
"sass-loader": "^7.1.0",
195+
"sass-loader": "^13.3.2",
193196
"semver": "^5.3.0",
194197
"strip-markdown": "^3.0.3",
195-
"style-loader": "^0.23.1",
196-
"terser-webpack-plugin": "^4.2.3",
198+
"style-loader": "^3.3.3",
199+
"terser-webpack-plugin": "^5.3.9",
197200
"three-full": "^28.0.2",
198201
"unist-util-visit": "^2.0.3",
199202
"uuid": "^8.3.2",
200203
"video.js": "^7.14.3",
201204
"videojs-contrib-quality-levels": "^2.0.9",
202205
"videojs-event-tracking": "^1.0.1",
203206
"villain-react": "^1.0.9",
204-
"webpack": "^4.44.2",
205-
"webpack-bundle-analyzer": "^3.1.0",
206-
"webpack-cli": "^3.3.10",
207+
"webpack": "^5.89.0",
208+
"webpack-bundle-analyzer": "^4.10.1",
209+
"webpack-cli": "^5.1.4",
207210
"webpack-config-utils": "^2.3.1",
208-
"webpack-dev-middleware": "^3.6.0",
209-
"webpack-dev-server": "^3.9.0",
210-
"webpack-hot-middleware": "^2.24.3",
211-
"webpack-merge": "^4.2.1",
212-
"webpack-node-externals": "^1.7.2",
211+
"webpack-dev-middleware": "^6.1.1",
212+
"webpack-dev-server": "^4.15.1",
213+
"webpack-hot-middleware": "^2.25.4",
214+
"webpack-merge": "^5.10.0",
215+
"webpack-node-externals": "^3.0.0",
213216
"yarnhook": "^0.2.0"
214217
},
215218
"engines": {
216-
"node": ">=16.13",
219+
"node": ">=20.0.0",
217220
"yarn": "^1.3"
218221
},
219222
"lbrySettings": {

postcss.config.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
module.exports = ({ file, options, env }) => {
2-
env = env || {};
3-
file = file || {};
4-
options = options || {};
5-
options.cssnext = options.cssnext || null;
6-
options.autoprefixer = options.autoprefixer || null;
7-
options.cssnano = options.cssnano || null;
8-
9-
return {
10-
parser: file.extname === '.sss' ? 'sugarss' : false,
11-
plugins: {
12-
'postcss-import': { root: file.dirname },
13-
cssnano: env === 'production' ? options.cssnano : false,
1+
module.exports = {
2+
plugins: {
3+
'postcss-import': {
4+
resolve: function (id) {
5+
// Handle ~ imports for node_modules
6+
if (id.startsWith('~')) {
7+
try {
8+
return require.resolve(id.substring(1));
9+
} catch (e) {
10+
return id;
11+
}
12+
}
13+
return id;
14+
}
1415
},
15-
};
16+
cssnano: process.env.NODE_ENV === 'production' ? {} : false,
17+
},
1618
};

webpack.base.config.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const TerserPlugin = require('terser-webpack-plugin');
88
const NODE_ENV = process.env.NODE_ENV || 'development';
99
const { ifProduction } = getIfUtils(NODE_ENV);
1010
const UI_ROOT = path.resolve(__dirname, 'ui/');
11-
const STATIC_ROOT = path.resolve(__dirname, 'static/');
1211

1312
let baseConfig = {
1413
mode: ifProduction('production', 'development'),
@@ -17,7 +16,9 @@ let baseConfig = {
1716
minimizer: [
1817
new TerserPlugin({
1918
parallel: true,
20-
sourceMap: true,
19+
terserOptions: {
20+
sourceMap: true,
21+
},
2122
}),
2223
],
2324
},
@@ -41,14 +42,17 @@ let baseConfig = {
4142
use: [
4243
{ loader: 'style-loader' },
4344
{ loader: 'css-loader' },
44-
{ loader: 'postcss-loader',
45+
{
46+
loader: 'postcss-loader',
4547
options: {
46-
plugins: function () {
47-
return [ require('postcss-rtl')() ];
48+
postcssOptions: {
49+
plugins: function () {
50+
return [require('postcss-rtl')()];
51+
},
4852
},
4953
},
5054
},
51-
{ loader: 'sass-loader'},
55+
{ loader: 'sass-loader' },
5256
],
5357
},
5458
{
@@ -95,8 +99,10 @@ let baseConfig = {
9599
},
96100

97101
plugins: [
98-
new webpack.IgnorePlugin({resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/}),
99-
new webpack.EnvironmentPlugin(['NODE_ENV']),
102+
new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }),
103+
new webpack.EnvironmentPlugin({
104+
NODE_ENV: 'development' // default value if NODE_ENV is not defined
105+
}),
100106
new DefinePlugin({
101107
__static: `"${path.join(__dirname, 'static').replace(/\\/g, '\\\\')}"`,
102108
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),

webpack.electron.config.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
const config = require('./config');
21
const path = require('path');
3-
const webpack = require('webpack');
4-
const merge = require('webpack-merge');
2+
const { merge } = require('webpack-merge');
53
const baseConfig = require('./webpack.base.config.js');
64
const CopyWebpackPlugin = require('copy-webpack-plugin');
75
const { DefinePlugin, ProvidePlugin } = require('webpack');
8-
const { getIfUtils, removeEmpty } = require('webpack-config-utils');
9-
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
10-
116
const STATIC_ROOT = path.resolve(__dirname, 'static/');
127
const DIST_ROOT = path.resolve(__dirname, 'dist/');
13-
const NODE_ENV = process.env.NODE_ENV || 'development';
14-
15-
const { ifProduction } = getIfUtils(NODE_ENV);
168

179
let mainConfig = {
1810
target: 'electron-main',
@@ -74,7 +66,6 @@ if (process.env.NODE_ENV === 'production') {
7466
},
7567
});
7668
} else {
77-
const nodeExternals = require('webpack-node-externals');
7869
// Apply dev overrides
7970
mainConfig = merge(mainConfig, {
8071
externals: {
@@ -94,17 +85,6 @@ let plugins = [
9485
}),
9586
];
9687

97-
// if (hasSentryToken) {
98-
// plugins.push(
99-
// new SentryWebpackPlugin({
100-
// include: './dist',
101-
// ignoreFile: '.sentrycliignore',
102-
// ignore: ['node_modules', 'webpack.config.js', 'webworkers'],
103-
// configFile: 'sentry.properties',
104-
// })
105-
// );
106-
// }
107-
10888
const renderConfig = {
10989
target: 'electron-renderer',
11090
entry: {

0 commit comments

Comments
 (0)