Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
// start the hot reload server
if (!isProduction) {
fuse.dev({
fallback: '../src/index.html',
port: DEV_PORT
});
}
// bundle the electron renderer code
const browser = fuse
.bundle('browser')
.target('browser@esnext')
.instructions('> example/todo/src/index.tsx')
.plugin(JSONPlugin())
.plugin(WebIndexPlugin({ template: './src/index.html' }))
.plugin(CSSPlugin({ inject: true }))
.plugin(
ReplacePlugin({
'process.env.NODE_ENV': `${process.env.NODE_ENV}`
})
);
const server = fuse
.bundle('server')
.target('server@esnext')
.instructions('> example/todo/server/index.ts -better-sqlite3');
if (!isProduction) {
server.watch(
p =>
entry = entry.replace('./', '').replace(root, '')
}
// this.args &&
if (typeof output === 'string') {
output = output
.replace('./', '')
.replace(root, '')
.replace('[name]', '$name')
}
// log.quick(this.args, instructions, root, workflow)
// log.quick({entry, output})
return {
plugins: [HTMLPlugin({default: true}), JSONPlugin()],
entry,
output,
}
}
}
const renderer = (name, port) => {
const cfg = getRendererConfig('electron', name);
cfg.plugins.push(getWebIndexPlugin(name));
cfg.plugins.push(JSONPlugin());
cfg.plugins.push(getCopyPlugin());
cfg.plugins.push(StyledComponentsPlugin());
const fuse = FuseBox.init(cfg);
if (!production) {
fuse.dev({ httpServer: true, port, socketURI: `ws://localhost:${port}` });
}
const app = fuse.bundle(name).instructions(`> [renderer/${name}/index.tsx]`);
if (!production) {
app.hmr({ port, socketURI: `ws://localhost:${port}` }).watch();
if (name === 'app') {
return fuse.run().then(() => {
const renderer = name => {
const cfg = getRendererConfig('electron');
cfg.plugins.push(getWebIndexPlugin(name));
cfg.plugins.push(JSONPlugin());
cfg.plugins.push(getCopyPlugin());
cfg.plugins.push(StyledComponentsPlugin());
const fuse = FuseBox.init(cfg);
let instructions = `> [renderer/views/${name}/index.tsx]`;
if (production) {
instructions = `> renderer/views/${name}/index.tsx -node-vibrant -electron -electron-extensions -styled-components -node-bookmarks-parser`;
}
const app = fuse.bundle(name).instructions(instructions);
if (!production) {
if (name === 'app') {
fuse.dev({ httpServer: true });
const web = name => {
const cfg = getWebConfig(name);
cfg.plugins.push(getWebIndexPlugin(name));
cfg.plugins.push(JSONPlugin());
cfg.plugins.push(getCopyPlugin());
cfg.plugins.push(StyledComponentsPlugin());
const fuse = FuseBox.init(cfg);
const app = fuse
.bundle(name)
.instructions(`> renderer/externals/${name}/index.tsx`);
app.hmr({ reload: true }).watch();
fuse.run();
};
static getFuseConfig(target, name, output = '$name.js', plugins = []) {
return {
target,
homeDir: './',
output: join(outputDir, output),
tsConfig: './tsconfig.json',
useTypescriptCompiler: true,
cache: !production,
plugins: [
EnvPlugin({
NODE_ENV: production ? 'production' : 'development',
}),
JSONPlugin(),
production &&
QuantumPlugin({
bakeApiIntoBundle: name,
treeshake: true,
removeExportsInterop: false,
uglify: {
es6: true,
},
}),
].concat(plugins),
log: {
showBundledFiles: false,
clearTerminalOnBundle: true,
},
alias: {
'@ui': '~/src/',
output: join(outputDir, output),
tsConfig: './tsconfig.json',
useTypescriptCompiler: true,
sourceMaps: !production,
cache: !production,
plugins: [
EnvPlugin({
NODE_ENV: production ? 'production' : 'development',
HOSTNAME,
USER,
PASSWORD,
PROTOCOL,
PORT,
ENABLED,
}),
JSONPlugin(),
production &&
QuantumPlugin({
bakeApiIntoBundle: name,
treeshake: true,
removeExportsInterop: false,
uglify: {
es6: true,
},
}),
].concat(plugins),
alias: {
'~': '~/',
'@renderer': '~/renderer/',
},
log: {
showBundledFiles: false,