Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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