Jon Holman
02/01/2022, 7:57 PMnpx sst deploy --stage test
run in the frontend directory? Can someone point me to the code for sst deploy
?thdxr
02/01/2022, 8:11 PMJon Holman
02/01/2022, 8:19 PMconst site = new sst.StaticSite(this, "AngularSite", {
path: "frontend",
buildOutput: "dist",
buildCommand: "ng build --output-path dist",
errorPage: sst.StaticSiteErrorOptions.REDIRECT_TO_INDEX_PAGE,
// Pass in our environment variables
environment: {
ANGULAR_APP_REGION: scope.region,
ANGULAR_APP_BUCKET: bucket.bucketName,
ANGULAR_APP_USER_POOL_ID: auth.cognitoUserPool.userPoolId,
ANGULAR_APP_IDENTITY_POOL_ID: auth.cognitoCfnIdentityPool.ref,
ANGULAR_APP_USER_POOL_CLIENT_ID:
auth.cognitoUserPoolClient.userPoolClientId,
},
});
Jon Holman
02/01/2022, 8:20 PMthdxr
02/01/2022, 8:50 PMthdxr
02/01/2022, 8:50 PMbuildOutput
to s3Jon Holman
02/01/2022, 9:02 PMJon Holman
02/01/2022, 9:06 PMsst-env -- npm run config
but if I add that to build I get an errorJon Holman
02/01/2022, 9:24 PMconst site = new sst.StaticSite(this, "AngularSite", {
path: "frontend",
buildOutput: "dist",
buildCommand: "echo ANGULAR_APP_REGION $ANGULAR_APP_REGION && echo ANGULAR_APP_BUCKET $ANGULAR_APP_BUCKET && npm run build",
errorPage: sst.StaticSiteErrorOptions.REDIRECT_TO_INDEX_PAGE,
// Pass in our environment variables
environment: {
ANGULAR_APP_REGION: scope.region,
ANGULAR_APP_BUCKET: bucket.bucketName,
ANGULAR_APP_USER_POOL_ID: auth.cognitoUserPool.userPoolId,
ANGULAR_APP_IDENTITY_POOL_ID: auth.cognitoCfnIdentityPool.ref,
ANGULAR_APP_USER_POOL_CLIENT_ID:
auth.cognitoUserPoolClient.userPoolClientId,
},
});
Jon Holman
02/01/2022, 9:24 PMANGULAR_APP_REGION us-east-1
ANGULAR_APP_BUCKET {{ ANGULAR_APP_BUCKET }}
Jon Holman
02/01/2022, 9:24 PMthdxr
02/01/2022, 10:05 PM{{ ANGULAR_APP_BUCKET }}
which get inlined into your code then uploaded to s3. Once the value is available, we have a lambda function that scans your files and replaces placeholders with the real value.
Really complicated which is why we try to hide that from you and works for 99% of cases but it breaks when something about the build process is dependent on knowing the value.Jon Holman
02/01/2022, 10:27 PMthdxr
02/01/2022, 10:45 PMbuild
, only after. We need to build first before we can ship anything to aws and get those valuesthdxr
02/01/2022, 10:45 PMJon Holman
02/01/2022, 11:38 PMthdxr
02/01/2022, 11:50 PMthdxr
02/01/2022, 11:51 PMthdxr
02/01/2022, 11:52 PMJon Holman
02/02/2022, 12:16 AMJon Holman
02/02/2022, 12:17 AMnpm run config
runs ts-node ./scripts/setenv.ts
which creates the environment.ts fileJon Holman
02/02/2022, 12:17 AMnpm run build
to npm run config -- && ng build --optimization=false --build-optimizer=false
Jon Holman
02/02/2022, 12:20 AMthdxr
02/02/2022, 12:41 AMthdxr
02/02/2022, 12:42 AMthdxr
02/02/2022, 12:42 AMmanitej
02/02/2022, 12:45 AMJon Holman
02/02/2022, 12:45 AMJon Holman
02/02/2022, 1:41 AMJon Holman
02/02/2022, 1:53 AMnpm run config
should be before ng build
right?Jon Holman
02/02/2022, 2:24 AMmanitej
02/02/2022, 11:30 AMJon Holman
02/02/2022, 2:37 PMsst start
and npm start
. I need to change how I did this last night.manitej
02/02/2022, 2:40 PMmanitej
02/02/2022, 2:41 PMthdxr
02/02/2022, 2:46 PMthdxr
02/02/2022, 2:46 PMng
specific constructmanitej
02/02/2022, 2:50 PMprocess.env
thdxr
02/02/2022, 2:51 PMmanitej
02/02/2022, 2:52 PMJon Holman
02/02/2022, 2:55 PMsst deploy
. While we need the script for local. That tripped me up initially as I was thinking that was similar to angular's enableProdMode()
Jon Holman
02/02/2022, 3:08 PM--
in sst-env -- npm run config && ng serve
?Jon Holman
02/02/2022, 3:54 PM--
I'm gathering --
is saying run the following command with the SST environment variables set.thdxr
02/02/2022, 4:00 PM--
is a convention used in scripts to seperate things you forward along vs flags to the commandJon Holman
02/02/2022, 4:17 PM--
and execute it?thdxr
02/02/2022, 4:18 PMenvironment
thdxr
02/02/2022, 4:18 PMng
has support for reading env variablesJon Holman
02/02/2022, 4:21 PM"createLocalConfig": "ts-node ./scripts/createLocalConfig.ts",
"start": "sst-env -- npm run createLocalConfig && ng serve",
Jon Holman
02/02/2022, 4:22 PMJon Holman
02/02/2022, 4:24 PM