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

feat: exclude common unnecessary files by default #23

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/nodejs-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export interface NodejsBuildProps {
* @default false
*/
readonly outputEnvFile?: boolean;
/**
* If true, common unnecessary files/directories such as .DS_Store, .git, node_modules, etc are excluded
* from the assets by default.
* @default true
*/
readonly excludeCommonFiles?: boolean;
}

/**
Expand Down Expand Up @@ -229,9 +235,11 @@ curl -v -i -X PUT -H 'Content-Type:' -d "@payload.json" "$responseURL"

this.grantPrincipal = project.grantPrincipal;

const commonExclude = ['.DS_Store', '.git', 'node_modules'];
const assets = props.assets.map((assetProps) => {
const asset = new Asset(this, `Source-${assetProps.path.replace('/', '')}`, {
...assetProps,
...(props.excludeCommonFiles ?? true ? { exclude: [...commonExclude, ...(assetProps.exclude ?? [])] } : {}),
});
asset.grantRead(project);
return asset;
Expand Down
2 changes: 1 addition & 1 deletion test/integ.nodejs-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TestStack extends Stack {
assets: [
{
path: '../example/example-app',
exclude: ['dist', 'node_modules'],
exclude: ['dist'],
},
],
destinationBucket: dstBucket,
Expand Down