flecks/packages/electron/build/flecks.bootstrap.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-02-07 19:33:27 -06:00
const {join, relative} = require('path');
const {binaryPath} = require('@flecks/core/src/server');
2024-01-16 00:28:20 -06:00
exports.hooks = {
'@flecks/core.config': () => ({
/**
* Browser window options.
*
* See: https://www.electronjs.org/docs/latest/api/browser-window
*/
browserWindowOptions: {},
/**
* Install devtools extensions (by default).
*
* You can pass an array of Chrome store IDs to install a list of custom extensions.
*/
installExtensions: true,
/**
* Quit the app when all windows are closed.
*/
quitOnClosed: true,
/**
* The URL to load in electron by default.
*
* Defaults to `http://${flecks.get('@flecks/web.public')}`.
*/
url: undefined,
}),
'@flecks/build.config.alter': async (configs) => {
const electronPath = await binaryPath('electron', '@flecks/electron');
const {server} = configs;
if (server) {
const plugin = server.plugins.find(({pluginName}) => pluginName === 'StartServerPlugin');
2024-01-16 00:28:20 -06:00
if (plugin) {
const relativePath = relative(server.output.path, electronPath);
2024-01-16 00:28:20 -06:00
const {exec} = plugin.options;
plugin.options.exec = (compilation) => {
2024-02-07 19:33:27 -06:00
plugin.options.args = [join(server.output.path, compilation.getPath(exec))];
return relativePath;
2024-01-16 00:28:20 -06:00
};
}
}
},
};