Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

static-site: fix formatting of sst-env.d.ts with Vite env vars #1042

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions platform/src/components/base/base-static-site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,18 @@ export function prepare(args: BaseStaticSiteArgs) {

// Create type file
const filePath = path.resolve(path.join(sitePath, typesPath));
const content = `/// <reference types="vite/client" />
interface ImportMetaEnv {
${Object.keys(environment)
.map((key) => ` readonly ${key}: string`)
.join("\n")}
}
interface ImportMeta {
readonly env: ImportMetaEnv
}`;
const content = `/* This file is auto-generated by SST. Do not edit. */
/* tslint:disable */
/* eslint-disable */
/// <reference types="vite/client" />
interface ImportMetaEnv {
${Object.keys(environment)
.map((key) => ` readonly ${key}: string`)
.join("\n")}
}
interface ImportMeta {
readonly env: ImportMetaEnv
}`;

const fileDir = path.dirname(filePath);
fs.mkdirSync(fileDir, { recursive: true });
Expand Down