diff --git a/_api/README.md b/_api/README.md index 1b80694..e4fb8e3 100644 --- a/_api/README.md +++ b/_api/README.md @@ -10,7 +10,7 @@ This repository contains scripts to deploy static files from the `_api/dist` dir ### Usage -Set the `ROOT_DIR` environment variable to specify the network type (e.g., `testnets`, `devnets`). +Set the `NETWORK_DIR` environment variable to specify the network type (e.g., `testnets`, `devnets`). Run the script: @@ -21,5 +21,5 @@ pnpm build or ```sh -ROOT_DIR=testnets pnpm build +NETWORK_DIR=testnets pnpm build ``` diff --git a/_api/package.json b/_api/package.json index 789a23e..47a5c58 100644 --- a/_api/package.json +++ b/_api/package.json @@ -1,4 +1,5 @@ { + "type": "module", "scripts": { "build": "tsx src/main.ts" }, diff --git a/_api/src/main.ts b/_api/src/main.ts index 977794f..f3b0549 100644 --- a/_api/src/main.ts +++ b/_api/src/main.ts @@ -12,12 +12,16 @@ */ import * as path from "path" +import * as url from "url" import { copyDirectory, deleteDirectory, getFilePathsInDirectory } from "./utils" import { updateUrlsInDirectory, createUrlReplacer } from "./replaceUrls" import { aggregateChainData } from "./aggregateChains" import { optimizeImages } from "./optimizeImages" -const rootDir = process.env.ROOT_DIR || "" +const __filename = url.fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) + +const rootDir = process.env.NETWORK_DIR || "" const srcDir = path.resolve(__dirname, "../..", rootDir) const distDir = path.resolve(__dirname, "../dist") diff --git a/_api/tsconfig.json b/_api/tsconfig.json index 97cb33b..b6937bd 100644 --- a/_api/tsconfig.json +++ b/_api/tsconfig.json @@ -1,3 +1,4 @@ { - "extends": "@tsconfig/recommended/tsconfig.json" + "extends": "@tsconfig/recommended/tsconfig.json", + "compilerOptions": { "module": "ESNext" } }