Amplify-cli: Amplify function specify source location

Created on 10 Sep 2019  路  5Comments  路  Source: aws-amplify/amplify-cli

Note: If your question is regarding the AWS Amplify Console service, please log it in the
official AWS Amplify Console forum

* Which Category is your question related to? *
Amplify Cli functions
* What AWS Services are you utilizing? *
Appysync, dynamo, lambda
* Provide additional details e.g. code snippets *
I couldn't find my answer in the docs for amplify or in the more general aws docs for functions.

I have an amplify project with a function that I originally created with all the code in src/ but I have now added webpack to package up the function code which outputs to src/bin. How do I tell amplify to target that specific directory to create the zip that it puts in the dist/ dir?
i.e I would like to zip the output of webpack not the src.

It looks like it runs my script "amplify:my-function": "npm run lint && npm run webpack"

I tried changing the lambda function aws:asset:path in the medatadate section in cloud formation template but I don't think its used here

enhancement functions pending-review

Most helpful comment

Hi! Any news on this one? Or any other suggestion on how to effectively minify the code without any "hacks" around the amplify conventions?

References

All 5 comments

@set321go
What's the value of the aws:asset:path that you put in your cloudformation template?

"aws:asset:path": "./src" I tried changing it to ./src/bin but after building the function dist/lastest-build.zip still includes all of ./src

@set321go The build process happens out here - https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-provider-awscloudformation/lib/build-resources.js#L21 and as you can see this is hard-coded to the src/ directory right now..so I would treat this request as an enhancement.

Hi! Any news on this one? Or any other suggestion on how to effectively minify the code without any "hacks" around the amplify conventions?

References

Should work if you put the code somewhere else and webpack to src?

Was this page helpful?
0 / 5 - 0 ratings