Skip to content

Commit

Permalink
Notifications (#23)
Browse files Browse the repository at this point in the history
* notifications and typescriptification

* add copyright and license notice
  • Loading branch information
arvid220u authored Apr 3, 2022
1 parent f5a9eaa commit 2a66de3
Show file tree
Hide file tree
Showing 17 changed files with 756 additions and 261 deletions.
2 changes: 1 addition & 1 deletion gui/helpers/configs/webpack.config.main.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const configuration: webpack.Configuration = {

entry: {
main: path.join(webpackPaths.srcMainPath, "main.ts"),
preload: path.join(webpackPaths.srcMainPath, "preload.js"),
preload: path.join(webpackPaths.srcMainPath, "preload.ts"),
},

output: {
Expand Down
73 changes: 73 additions & 0 deletions gui/helpers/configs/webpack.config.preload.dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// Copyright 2022 Anysphere, Inc.
// SPDX-License-Identifier: GPL-3.0-only
//

import path from "path";
import webpack from "webpack";
import { merge } from "webpack-merge";
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
import baseConfig from "./webpack.config.base";
import webpackPaths from "./webpack.paths";
import checkNodeEnv from "../scripts/check-node-env";

// When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's
// at the dev webpack config is not accidentally run in a production environment
if (process.env.NODE_ENV === "production") {
checkNodeEnv("development");
}

const configuration: webpack.Configuration = {
devtool: "inline-source-map",

mode: "development",

target: "electron-preload",

entry: path.join(webpackPaths.srcMainPath, "preload.ts"),

output: {
path: webpackPaths.dllPath,
filename: "preload.js",
},

plugins: [
new BundleAnalyzerPlugin({
analyzerMode: process.env.ANALYZE === "true" ? "server" : "disabled",
}),

/**
* Create global constants which can be configured at compile time.
*
* Useful for allowing different behaviour between development builds and
* release builds
*
* NODE_ENV should be production so that modules do not perform certain
* development checks
*
* By default, use 'development' as NODE_ENV. This can be overriden with
* 'staging', for example, by changing the ENV variables in the npm scripts
*/
new webpack.EnvironmentPlugin({
NODE_ENV: "development",
}),

new webpack.LoaderOptionsPlugin({
debug: true,
}),
],

/**
* Disables webpack processing of __dirname and __filename.
* If you run the bundle in node.js it falls back to these values of node.js.
* https://github.com/webpack/webpack/issues/2010
*/
node: {
__dirname: false,
__filename: false,
},

watch: true,
};

export default merge(baseConfig, configuration);
18 changes: 15 additions & 3 deletions gui/helpers/configs/webpack.config.renderer.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: GPL-3.0-only
//

import "webpack-dev-server";
import path from "path";
import fs from "fs";
import webpack from "webpack";
Expand Down Expand Up @@ -138,7 +139,6 @@ const configuration: webpack.Configuration = {
__filename: false,
},

// @ts-ignore
devServer: {
port,
compress: true,
Expand All @@ -150,15 +150,27 @@ const configuration: webpack.Configuration = {
historyApiFallback: {
verbose: true,
},
onBeforeSetupMiddleware() {
setupMiddlewares(middlewares) {
console.log("Starting preload.js builder...");
const preloadProcess = spawn("npm", ["run", "start:preload"], {
shell: true,
stdio: "inherit",
})
.on("close", (code: number) => process.exit(code!))
.on("error", (spawnError) => console.error(spawnError));

console.log("Starting Main Process...");
spawn("npm", ["run", "start:main"], {
shell: true,
env: process.env,
stdio: "inherit",
})
.on("close", (code: number) => process.exit(code!))
.on("close", (code: number) => {
preloadProcess.kill();
process.exit(code!);
})
.on("error", (spawnError) => console.error(spawnError));
return middlewares;
},
},
};
Expand Down
Loading

0 comments on commit 2a66de3

Please sign in to comment.