Skip to content

Commit 9ca28b2

Browse files
authored
StaticSite: replace environment in all html files (#1533)
* StaticSite: replace environment in all html files * Sync
1 parent 7988449 commit 9ca28b2

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

packages/resources/src/StaticSite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ export class StaticSite extends Construct implements SSTConstruct {
615615
const token = `{{ ${key} }}`;
616616
replaceValues.push(
617617
{
618-
files: "index.html",
618+
files: "**/*.html",
619619
search: token,
620620
replace: value,
621621
},

packages/resources/test/ReactStaticSite.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ test("constructor: default replaceValues", async () => {
147147
hasResource(stack, "Custom::SSTBucketDeployment", {
148148
ReplaceValues: [
149149
{
150-
files: "index.html",
150+
files: "**/*.html",
151151
search: "{{ REACT_APP_REFERENCE_ENV }}",
152152
replace: { "Fn::GetAtt": ANY },
153153
},
@@ -185,7 +185,7 @@ test("constructor: default replaceValues override", async () => {
185185
replace: "value",
186186
},
187187
{
188-
files: "index.html",
188+
files: "**/*.html",
189189
search: "{{ REACT_APP_REFERENCE_ENV }}",
190190
replace: { "Fn::GetAtt": ANY },
191191
},

packages/resources/test/StaticSite.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ test("constructor: environment generates placeholders", async () => {
880880
hasResource(stack, "Custom::SSTBucketDeployment", {
881881
ReplaceValues: [
882882
{
883-
files: "index.html",
883+
files: "**/*.html",
884884
search: "{{ REFERENCE_ENV }}",
885885
replace: { "Fn::GetAtt": ANY },
886886
},
@@ -918,7 +918,7 @@ test("constructor: environment appends to replaceValues", async () => {
918918
replace: "value",
919919
},
920920
{
921-
files: "index.html",
921+
files: "**/*.html",
922922
search: "{{ REFERENCE_ENV }}",
923923
replace: { "Fn::GetAtt": ANY },
924924
},

packages/resources/test/ViteStaticSite.test.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import * as fs from "fs-extra";
2-
import {
3-
hasResource,
4-
objectLike,
5-
stringLike,
6-
ANY,
7-
} from "./helper";
2+
import { hasResource, objectLike, stringLike, ANY } from "./helper";
83
import { App, Api, Stack, ViteStaticSite } from "../src";
94

105
beforeEach(async () => {
@@ -89,9 +84,7 @@ test("constructor: default buildCommand", async () => {
8984
},
9085
});
9186
const indexHtml = fs.readFileSync("test/vite-static-site/dist/index.html");
92-
expect(indexHtml.toString().trim()).toBe(
93-
"my-url {{ VITE_REFERENCE_ENV }}"
94-
);
87+
expect(indexHtml.toString().trim()).toBe("my-url {{ VITE_REFERENCE_ENV }}");
9588
});
9689

9790
test("constructor: default buildCommand override", async () => {
@@ -165,7 +158,7 @@ test("constructor: default replaceValues", async () => {
165158
hasResource(stack, "Custom::SSTBucketDeployment", {
166159
ReplaceValues: [
167160
{
168-
files: "index.html",
161+
files: "**/*.html",
169162
search: "{{ VITE_REFERENCE_ENV }}",
170163
replace: { "Fn::GetAtt": ANY },
171164
},
@@ -203,7 +196,7 @@ test("constructor: default replaceValues override", async () => {
203196
replace: "value",
204197
},
205198
{
206-
files: "index.html",
199+
files: "**/*.html",
207200
search: "{{ VITE_REFERENCE_ENV }}",
208201
replace: { "Fn::GetAtt": ANY },
209202
},

0 commit comments

Comments
 (0)