<|start_filename|>electron-builder.json<|end_filename|>
{
  "appId": "io.github.unageek.graphest",
  "directories": {
    "output": "./release"
  },
  "files": ["./dist/**/*", "!**/*.js.map"],
  "afterSign": "./scripts/afterSign.js",
  "mac": {
    "category": "public.app-category.utilities",
    "electronLanguages": ["en"]
  },
  "nsis": {
    "oneClick": false,
    "allowToChangeInstallationDirectory": true
  }
}


<|start_filename|>scripts/afterSign.js<|end_filename|>
require("dotenv").config();

const { notarize } = require("electron-notarize");
const path = require("path");
const build = require("../electron-builder.json");

module.exports = async function (params) {
  if (params.electronPlatformName !== "darwin") return;

  const appBundleId = build.appId;
  const appPath = path.join(
    params.appOutDir,
    `${params.packager.appInfo.productFilename}.app`
  );

  console.log(`Notarizing ${appBundleId} found at ${appPath}`);

  await notarize({
    appBundleId,
    appPath,
    appleId: process.env.notarizeAppleId,
    appleIdPassword: process.env.notarizeAppleIdPassword,
  });
};


<|start_filename|>webpack.config.js<|end_filename|>
const ESLintPlugin = require("eslint-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const process = require("process");

function baseConfig() {
  return {
    ...(() => {
      switch (process.env.NODE_ENV) {
        case "development":
          return {
            devtool: "cheap-source-map",
            mode: "development",
            stats: "errors-warnings",
          };
        case "production":
          return {
            mode: "production",
            stats: "errors-warnings",
          };
        default:
          throw new Error(
            "set either NODE_ENV=development or NODE_ENV=production"
          );
      }
    })(),
    output: {
      path: path.resolve(__dirname, "dist"),
      filename: "[name].js",
    },
  };
}

const tsLoaderRule = {
  include: path.resolve(__dirname, "src"),
  test: /\.ts$/,
  resolve: {
    extensions: [".ts", ".js"],
  },
  use: "ts-loader",
};

const plugins = [
  new ESLintPlugin({
    extensions: ["js", "ts", "tsx"],
    fix: true,
  }),
];

function mainConfig() {
  return {
    ...baseConfig(),
    target: "electron-main",
    entry: "./src/main/main.ts",
    module: {
      rules: [tsLoaderRule],
    },
    plugins,
  };
}

function preloadConfig() {
  return {
    ...baseConfig(),
    target: "electron-preload",
    entry: { preload: "./src/renderer/preload.ts" },
    module: {
      rules: [tsLoaderRule],
    },
    plugins,
  };
}

function rendererConfig() {
  return {
    ...baseConfig(),
    target: "electron-renderer",
    entry: { bundle: "./src/renderer/App.tsx" },
    module: {
      rules: [
        {
          test: /\.css$/,
          use: ["style-loader", "css-loader"],
        },
        {
          test: /\.(eot|png|svg|ttf|woff|woff2)$/,
          type: "asset/resource",
        },
        {
          ...tsLoaderRule,
          test: /\.tsx?$/,
          resolve: {
            extensions: [".ts", ".tsx", ".js"],
          },
        },
      ],
    },
    plugins: [
      ...plugins,
      new HtmlWebpackPlugin({
        template: "./src/renderer/index.html",
      }),
    ],
  };
}

module.exports = [mainConfig(), preloadConfig(), rendererConfig()];
