Skip to content

Commit 4ee141c

Browse files
committed
refactor: extract configs
1 parent c50c9ca commit 4ee141c

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

templates/hyperweb/scripts/build.ts

+6-18
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,24 @@
1-
import { HyperwebBuild, HyperwebBuildOptions } from '@hyperweb/build';
2-
import { join } from 'path';
1+
import { HyperwebBuild, HyperwebBuildOptions } from "@hyperweb/build";
2+
import { join } from "path";
33

4-
interface BuildConfig {
5-
entryFile: string;
6-
outFile: string;
7-
externalPackages: string[];
8-
}
9-
10-
const configs: BuildConfig[] = [
11-
{
12-
entryFile: 'src/simple-state/index.ts',
13-
outFile: 'dist/contracts/simpleState.js',
14-
externalPackages: ['otherpackage', '~somepackage']
15-
}
16-
];
4+
import { configs, type BuildConfig } from "./configs";
175

18-
const rootDir = join(__dirname, '/../');
6+
const rootDir = join(__dirname, "/../");
197

208
async function buildInterweb(config: BuildConfig): Promise<void> {
219
const { entryFile, outFile, externalPackages } = config;
2210

2311
const options: Partial<HyperwebBuildOptions> = {
2412
entryPoints: [join(rootDir, entryFile)],
2513
outfile: join(rootDir, outFile),
26-
external: externalPackages
14+
external: externalPackages,
2715
};
2816

2917
try {
3018
await HyperwebBuild.build(options);
3119
console.log(`Build completed successfully! Output: ${options.outfile}`);
3220
} catch (error) {
33-
console.error('Build failed:', error);
21+
console.error("Build failed:", error);
3422
throw error;
3523
}
3624
}

templates/hyperweb/scripts/configs.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export interface BuildConfig {
2+
entryFile: string;
3+
outFile: string;
4+
externalPackages: string[];
5+
}
6+
7+
export const configs: BuildConfig[] = [
8+
{
9+
entryFile: "src/simple-state/index.ts",
10+
outFile: "dist/contracts/simpleState.js",
11+
externalPackages: ["otherpackage", "~somepackage"],
12+
},
13+
];

0 commit comments

Comments
 (0)