:electron: Separate build folders for easier switching between web and electron (#3801)

* seperate build folders for easier switching between web and electron builds

* gitignore

* release notes

* one directory back from electron

* spelling mistake

* Update 3801.md

* test

* making it correct

* huh

* urghh

* again

* account for api bundle which uses electron bundle for some reason

* hu-

* lets go

* remove comment
This commit is contained in:
Michael Clark
2024-11-12 18:39:49 +00:00
committed by GitHub
parent d1324408f4
commit 1e1092e472
9 changed files with 27 additions and 16 deletions

View File

@@ -36,7 +36,7 @@ fi
yarn workspace loot-core build:node
yarn workspace @actual-app/web build --mode=desktop
yarn workspace @actual-app/web build --mode=desktop # electron specific build
yarn workspace desktop-electron update-client

View File

@@ -10,6 +10,7 @@ playwright-report
# production
build
build-electron
build-stats
stats.json

View File

@@ -15,7 +15,7 @@ const addWatchers = (): Plugin => ({
configureServer(server) {
server.watcher
.add([
path.resolve('../loot-core/lib-dist/*.js'),
path.resolve('../loot-core/lib-dist/electron/*.js'),
path.resolve('../loot-core/lib-dist/browser/*.js'),
])
.on('all', function () {
@@ -109,7 +109,7 @@ export default defineConfig(async ({ mode }) => {
build: {
target: 'es2022',
sourcemap: true,
outDir: 'build',
outDir: mode === 'desktop' ? 'build-electron' : 'build',
assetsDir: 'static',
manifest: true,
assetsInlineLimit: 0,
@@ -148,7 +148,7 @@ export default defineConfig(async ({ mode }) => {
extensions: resolveExtensions,
},
plugins: [
// Macos electron (desktop) builds do not support PWA
// electron (desktop) builds do not support PWA
mode === 'desktop'
? undefined
: VitePWA({

View File

@@ -4,7 +4,7 @@ ROOT=`dirname $0`/..
rm -rf ${ROOT}/build
mkdir -p ${ROOT}/build
cp -r ${ROOT}/../desktop-client/build ${ROOT}/build/client-build
cp -r ${ROOT}/../desktop-client/build-electron ${ROOT}/build/client-build
# Remove the embedded backend for the browser version. Will improve
# this process
@@ -14,9 +14,8 @@ rm -rf ${ROOT}/build/client-build/*.wasm
rm -rf ${ROOT}/build/client-build/*.map
# Copy loot-core into build directory
mkdir -p ${ROOT}/build/loot-core/lib-dist
ls ${ROOT}/build/loot-core/lib-dist
cp ${ROOT}/../loot-core/lib-dist/bundle.desktop.js ${ROOT}/build/loot-core/lib-dist/bundle.desktop.js
mkdir -p ${ROOT}/build/loot-core/lib-dist/electron
cp ${ROOT}/../loot-core/lib-dist/electron/bundle.desktop.js ${ROOT}/build/loot-core/lib-dist/electron/bundle.desktop.js
cp ${ROOT}/../loot-core/default-db.sqlite ${ROOT}/build/loot-core/default-db.sqlite
cp -r ${ROOT}/../loot-core/migrations ${ROOT}/build/loot-core/migrations

View File

@@ -32,8 +32,8 @@ import './security';
const isDev = !app.isPackaged; // dev mode if not packaged
process.env.lootCoreScript = isDev
? 'loot-core/lib-dist/bundle.desktop.js' // serve from local output in development (provides hot-reloading)
: path.resolve(__dirname, 'loot-core/lib-dist/bundle.desktop.js'); // serve from build in production
? 'loot-core/lib-dist/electron/bundle.desktop.js' // serve from local output in development (provides hot-reloading)
: path.resolve(__dirname, 'loot-core/lib-dist/electron/bundle.desktop.js'); // serve from build in production
// This allows relative URLs to be resolved to app:// which makes
// local assets load correctly

View File

@@ -21,7 +21,7 @@
"!**/*.js.map",
"!**/stats.json",
"!build/client-build/sql-wasm.wasm",
"!build/loot-core/lib-dist/{browser,bundle.mobile*}"
"!build/loot-core/lib-dist/electron/{browser,bundle.mobile*}"
],
"beforePack": "./build/beforePackHook.js",
"mac": {

View File

@@ -10,10 +10,15 @@ export { getDocumentDir, getBudgetDir, _setDocumentDir } from './shared';
let rootPath = path.join(__dirname, '..', '..', '..', '..');
if (__filename.match('bundle')) {
// The file name is not our filename and indicates that we're in the
// bundled form. Because of this, the root path is different.
rootPath = path.join(__dirname, '..');
switch (path.basename(__filename)) {
case 'bundle.api.js': // api bundle uses the electron bundle - account for its file structure
rootPath = path.join(__dirname, '..');
break;
case 'bundle.desktop.js': // electron app
rootPath = path.join(__dirname, '..', '..');
break;
default:
break;
}
export const init = () => {

View File

@@ -11,7 +11,7 @@ module.exports = {
target: 'node',
devtool: 'source-map',
output: {
path: path.resolve(path.join(__dirname, '/../lib-dist')),
path: path.resolve(path.join(__dirname, '/../lib-dist/electron')),
filename: 'bundle.desktop.js',
sourceMapFilename: 'bundle.desktop.js.map',
libraryTarget: 'commonjs2',

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MikesGlitch]
---
Update build folder structure to allow separation of web and electron builds