aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.83k stars 822 forks source link

Amplify Front End Multi-Environments deployment #3691

Open rehanbabertkxel opened 4 years ago

rehanbabertkxel commented 4 years ago

Which Category is your question related to? Multi Environment Deployments

Amplify CLI Version 4.13.1

Provide additional details e.g. code snippets I am using different environment in my Font End Angular8 app and to build it in different environments, we have multiple commands like:

"build": "ng build --prod --configuration=dev", "build-test": "ng build --prod --configuration=test",

But when I run amplify publish, the Build command in project-config.json is:

npm run-script build

so this will only run with the dev configuration.

What is the best way to run it with the"test" configuration other than creating a new branch and changing the BuildCommand in that branch.

UnleashedMind commented 4 years ago

The project-config is tied to the frontend project type and not to each env, so yes, you need to change it when you have different build command for different env. Another option than creating a new branch would be to write a script for the build command, and in the script it first checks the env (information available as envName in amplify/.config/local-env-info, and invoke the different ng build configuration accordingly.

rehanbabertkxel commented 4 years ago

@UnleashedMind , do you have any plans of considering multiple front end environment during "amplify publish". If there can be a way to tell in the project-config.json to use front end environment according to the checkout amplify environment?

UnleashedMind commented 4 years ago

I'm marking this as a feature request then, will talk to the team and see if we can add this feature. will keep you posted.

rehanbabertkxel commented 4 years ago

@UnleashedMind , yeah that would be quite helpful for teams working with different front end environemnt.

master-of-null commented 3 years ago

I'm utilizing Amplify strictly for publishing my frontend React app, and I'm running into the same issue. I can't figure out how to have configure two different stages prod and dev, and deploy them separately, do different URLs

takumiecofit commented 3 years ago

for amplify publish and angular.

it's defaulting to ng build --prod. We don't have the option to substitute this with something else like ng build -c development. I can't find any documentation on how to extend amplify publish other than this:

https://docs.amplify.aws/cli/hosting

mattmilan-dev commented 2 years ago

Hi all,

I had the same issue here this morning, and also found a stackoverflow question asking the same question which i answered with our teams current solution. Hopefully this helps someone whilst the amplify team work on a first party solution:

https://stackoverflow.com/questions/60863600/how-to-run-a-different-build-command-for-staging-environment-when-publishing-a-r/71351306#71351306

josefaidt commented 2 years ago

Hey folks in the thread :wave: as a workaround, we can potentially leverage an environment variable and point our build script to reference this environment variable (i.e. ng build --configuration $MY_AMPLIFY_ENVIRONMENT)