Skip to content

Commit

Permalink
perf: create webpack bundle of main bootstrap
Browse files Browse the repository at this point in the history
in order to not ship unused node_modules and remove fs reads

ref #10
  • Loading branch information
Xiphe committed Apr 17, 2020
1 parent 6c64bbf commit 411e1ed
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules/
build/
app_asar/
dist/
dist.js
.DS_Store
5 changes: 1 addition & 4 deletions main/moneymoney/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { join } from 'path';
import { exec } from 'child_process';
import { parse } from 'plist';
import osascript from './osascript';

const scriptsDir = __dirname.includes('/app.asar/')
? join(process.resourcesPath, 'scripts')
: join((require as any).main.filename, '../../main/moneymoney');
import scriptsDir from '../scriptsDir';

function isDbLocked(err: any) {
return err.stderr && err.stderr.includes('Locked database. (-2720)');
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions main/scriptsDir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { join } from 'path';

export default __dirname.includes('/app.asar/')
? join(process.resourcesPath, 'scripts')
: join(__dirname, 'scripts');
4 changes: 1 addition & 3 deletions main/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"noEmit": false,
"outDir": "./dist"
"noEmit": false
},
"include": ["./*.ts"]
}
28 changes: 28 additions & 0 deletions main/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
mode: 'production',
entry: './main/index.ts',
target: 'node',
externals: {
electron: 'electron',
},
node: {
__dirname: false,
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
filename: 'dist.js',
libraryTarget: 'commonjs2',
path: __dirname,
},
};
2 changes: 1 addition & 1 deletion main/windowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function createWindowManager(ipcMain: IpcMain) {
win.loadURL(SERVER_URL);
win.webContents.openDevTools();
} else {
win.loadFile(join(__dirname, '../../build/index.html'));
win.loadFile(join(__dirname, '../build/index.html'));
}

if (file) {
Expand Down
Loading

0 comments on commit 411e1ed

Please sign in to comment.