Skip to content

Commit

Permalink
fix: config exclude (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
sahinvardar authored May 16, 2024
1 parent 83eea02 commit c579a25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
3 changes: 3 additions & 0 deletions example/react-app/public/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"region": "TODO"
}
3 changes: 3 additions & 0 deletions example/svelte-app/static/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"region": "TODO"
}
15 changes: 2 additions & 13 deletions src/spa-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from '
import { Construct } from 'constructs';

export interface SpaAppConstructProps {
/**
* The name for the backing s3 Bucket.
*
* Remarks
* In case you define a @see domainName, the name of the bucket will be
* the same as @see domainName
*/
bucketName?: string;

/**
* Optional config object which will be used to generate a `config.json` file
* in the root of the SpaApp deployment.
Expand Down Expand Up @@ -96,10 +87,7 @@ export class SpaApp extends Construct {
public readonly cloudFrontUrl: string;

createBucket() {
const bucketName = (this.stackProps.domain && this.stackProps.domain.domainName) || this.stackProps.bucketName;

const bucket = new s3.Bucket(this, 'SpaAppBucket', {
bucketName,
removalPolicy: this.stackProps.removalPolicy,
autoDeleteObjects: this.stackProps.removalPolicy === RemovalPolicy.DESTROY
});
Expand All @@ -121,10 +109,11 @@ export class SpaApp extends Construct {
`find ${this.stackProps.spaBuildPath} -mindepth 1 -maxdepth 1 -type d -exec cp -r {} ${otherFilesDir} \\;`
);

new s3d.BucketDeployment(this, 'SpaAppIndexDeployment', {
new s3d.BucketDeployment(this, 'SpaAppRootFilesDeployment', {
destinationBucket: bucket,
sources: [s3d.Source.asset(rootFilesDir)],
cacheControl: [s3d.CacheControl.fromString('max-age=0, no-cache, no-store, must-revalidate')],
exclude: ['config.json'],
prune: false
});

Expand Down

0 comments on commit c579a25

Please sign in to comment.