2024-02-07 19:33:27 -06:00
|
|
|
const {join, relative} = require('path');
|
2024-02-07 15:40:08 -06:00
|
|
|
|
|
|
|
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,
|
|
|
|
}),
|
2024-02-07 15:40:08 -06:00
|
|
|
'@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) {
|
2024-02-07 15:40:08 -06:00
|
|
|
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))];
|
2024-02-07 15:40:08 -06:00
|
|
|
return relativePath;
|
2024-01-16 00:28:20 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|