Initial Settings UI work
This commit is contained in:
56
scripts/build/build.mts
Normal file
56
scripts/build/build.mts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { BuildContext, BuildOptions, context } from "esbuild";
|
||||
|
||||
const CommonOpts: BuildOptions = {
|
||||
minify: true,
|
||||
bundle: true,
|
||||
sourcemap: "linked",
|
||||
logLevel: "info"
|
||||
};
|
||||
|
||||
const NodeCommonOpts: BuildOptions = {
|
||||
...CommonOpts,
|
||||
format: "cjs",
|
||||
platform: "node",
|
||||
external: ["electron"],
|
||||
target: ["esnext"],
|
||||
};
|
||||
|
||||
const contexts = [] as BuildContext[];
|
||||
async function createContext(options: BuildOptions) {
|
||||
contexts.push(await context(options));
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
createContext({
|
||||
...NodeCommonOpts,
|
||||
entryPoints: ["src/main/index.ts"],
|
||||
outfile: "dist/js/main.js"
|
||||
}),
|
||||
createContext({
|
||||
...NodeCommonOpts,
|
||||
entryPoints: ["src/preload/index.ts"],
|
||||
outfile: "dist/js/preload.js"
|
||||
}),
|
||||
createContext({
|
||||
...CommonOpts,
|
||||
entryPoints: ["src/renderer/index.ts"],
|
||||
outfile: "dist/js/renderer.js",
|
||||
format: "iife",
|
||||
inject: ["./scripts/build/injectReact.mjs"],
|
||||
jsxFactory: "VencordCreateElement",
|
||||
jsxFragment: "VencordFragment",
|
||||
// Work around https://github.com/evanw/esbuild/issues/2460
|
||||
tsconfig: "./scripts/build/tsconfig.esbuild.json"
|
||||
})
|
||||
]);
|
||||
|
||||
const watch = process.argv.includes("--watch");
|
||||
|
||||
if (watch) {
|
||||
await Promise.all(contexts.map(ctx => ctx.watch()));
|
||||
} else {
|
||||
await Promise.all(contexts.map(async ctx => {
|
||||
await ctx.rebuild();
|
||||
await ctx.dispose();
|
||||
}));
|
||||
}
|
||||
3
scripts/build/injectReact.mjs
Normal file
3
scripts/build/injectReact.mjs
Normal file
@@ -0,0 +1,3 @@
|
||||
export const VencordFragment = /* #__PURE__*/ Symbol.for("react.fragment");
|
||||
export let VencordCreateElement =
|
||||
(...args) => (VencordCreateElement = Vencord.Webpack.Common.React.createElement)(...args);
|
||||
7
scripts/build/tsconfig.esbuild.json
Normal file
7
scripts/build/tsconfig.esbuild.json
Normal file
@@ -0,0 +1,7 @@
|
||||
// Work around https://github.com/evanw/esbuild/issues/2460
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"jsx": "react"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user