Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .erb/configs/webpack.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import webpack from 'webpack';
import webpackPaths from './webpack.paths';
import webpackPaths from './webpack.paths.ts';

// Keep JS deps bundled, but leave native modules as externals.
// better-sqlite3 relies on runtime native loading (bindings), which breaks when bundled.
Expand Down
9 changes: 5 additions & 4 deletions .erb/configs/webpack.config.main.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import path from 'path';
import webpack from 'webpack';
import { merge } from 'webpack-merge';
import TerserPlugin from 'terser-webpack-plugin';
// @ts-ignore no bundled types for this package in current config project
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import Dotenv from 'dotenv-webpack';
import baseConfig from './webpack.config.base';
import webpackPaths from './webpack.paths';
import checkNodeEnv from '../scripts/check-node-env';
import deleteSourceMaps from '../scripts/delete-source-maps';
import baseConfig from './webpack.config.base.ts';
import webpackPaths from './webpack.paths.ts';
import checkNodeEnv from '../scripts/check-node-env.js';
import deleteSourceMaps from '../scripts/delete-source-maps.js';

checkNodeEnv('production');
deleteSourceMaps();
Expand Down
6 changes: 3 additions & 3 deletions .erb/configs/webpack.config.renderer.dev.dll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import webpack from 'webpack';
import path from 'path';
import { merge } from 'webpack-merge';
import baseConfig from './webpack.config.base';
import webpackPaths from './webpack.paths';
import baseConfig from './webpack.config.base.ts';
import webpackPaths from './webpack.paths.ts';
import { dependencies } from '../../package.json';
import checkNodeEnv from '../scripts/check-node-env';
import checkNodeEnv from '../scripts/check-node-env.js';

checkNodeEnv('development');

Expand Down
16 changes: 9 additions & 7 deletions .erb/configs/webpack.config.renderer.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Dotenv from 'dotenv-webpack';
import chalk from 'chalk';
import { merge } from 'webpack-merge';
import { spawn, execSync } from 'node:child_process';
import baseConfig from './webpack.config.base';
import webpackPaths from './webpack.paths';
import checkNodeEnv from '../scripts/check-node-env';
import baseConfig from './webpack.config.base.ts';
import webpackPaths from './webpack.paths.ts';
import checkNodeEnv from '../scripts/check-node-env.js';
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';

// When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's
Expand All @@ -19,8 +19,9 @@ if (process.env.NODE_ENV === 'production') {

const port = process.env.PORT || 1212;
const manifest = path.resolve(webpackPaths.dllPath, 'renderer.json');
const requiredByDLLConfig = module.parent!.filename.includes(
'webpack.config.renderer.dev.dll'
const appNodeModulesPath = path.join(webpackPaths.rootPath, 'node_modules');
const requiredByDLLConfig = process.argv.some((arg) =>
arg.includes('webpack.config.renderer.dev.dll')
);

/**
Expand Down Expand Up @@ -179,7 +180,7 @@ const configuration: webpack.Configuration = {
isBrowser: false,
env: process.env.NODE_ENV,
isDevelopment: process.env.NODE_ENV !== 'production',
nodeModules: webpackPaths.appNodeModulesPath,
nodeModules: appNodeModulesPath,
}),
],

Expand Down Expand Up @@ -216,7 +217,8 @@ const configuration: webpack.Configuration = {
],
},
},
setupMiddlewares(middlewares) {
// @ts-ignore webpack-dev-server runtime typing mismatch in this config context
setupMiddlewares(middlewares: Array<unknown>, _devServer: unknown) {
// Only auto-start main process if DEBUG_MODE is not set
if (process.env.DEBUG_MODE !== 'true') {
console.log('Starting Main Process...');
Expand Down
9 changes: 5 additions & 4 deletions .erb/configs/webpack.config.renderer.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import Dotenv from 'dotenv-webpack';
// @ts-ignore no bundled types for this package in current config project
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
import { merge } from 'webpack-merge';
import TerserPlugin from 'terser-webpack-plugin';
import baseConfig from './webpack.config.base';
import webpackPaths from './webpack.paths';
import checkNodeEnv from '../scripts/check-node-env';
import deleteSourceMaps from '../scripts/delete-source-maps';
import baseConfig from './webpack.config.base.ts';
import webpackPaths from './webpack.paths.ts';
import checkNodeEnv from '../scripts/check-node-env.js';
import deleteSourceMaps from '../scripts/delete-source-maps.js';

checkNodeEnv('production');
deleteSourceMaps();
Expand Down
2 changes: 2 additions & 0 deletions .erb/configs/webpack.paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const dllPath = path.join(__dirname, '../dll');
const srcPath = path.join(rootPath, 'src', 'apps');
const srcMainPath = path.join(srcPath, 'main');
const srcRendererPath = path.join(srcPath, 'renderer');
const appNodeModulesPath = path.join(rootPath, 'node_modules');
const srcSyncPath = path.join(srcPath, 'workers', 'sync');
const srcBackupsPath = path.join(srcPath, 'backups');
const srcVirtualDrivePath = path.join(srcPath, 'drive');
Expand All @@ -27,6 +28,7 @@ export default {
srcPath,
srcMainPath,
srcRendererPath,
appNodeModulesPath,
distPath,
distMainPath,
distRendererPath,
Expand Down
25 changes: 25 additions & 0 deletions .erb/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"resolveJsonModule": true,
"types": [
"node"
],
"noEmit": true,
"skipLibCheck": true,
"allowImportingTsExtensions": true
},
"include": [
"./configs/**/*.ts",
"./configs/**/*.d.ts",
"../src/types/webpack-bundle-analyzer.d.ts"
],
"exclude": [
"../node_modules"
]
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build:renderer": "cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.prod.ts",
"rebuild": "electron-rebuild --parallel --types prod,dev,optional --module-dir .",
"reinstall:nautilus-extension": "NODE_ENV=development ts-node src/apps/main/nautilus-extension/reload.ts",
"lint": "cross-env NODE_ENV=development eslint . --ext .ts,.tsx --max-warnings=50",
"lint": "cross-env NODE_ENV=development eslint . --ext .ts,.tsx --max-warnings=20",
"lint:fix": "npm run lint --fix",
"format": "prettier src --check",
"format:fix": "prettier src --write",
Expand Down
8 changes: 8 additions & 0 deletions src/types/webpack-bundle-analyzer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare module 'webpack-bundle-analyzer' {
type BundleAnalyzerPluginOptions = Record<string, unknown>;

export class BundleAnalyzerPlugin {
constructor(options?: BundleAnalyzerPluginOptions);
apply(...args: unknown[]): void;
}
}
Loading