如何使用Gulp Process.env.node_env获得AWS放大以在生产模式下构建?
我正在使用以下配置使用AWS放大:
- https://dev.example.com/ - aws amplify -branch = dev
- https://example.com/ - aws amplify -branch = master = master
in gulpfile中。 js
我有规则适用于生产(使用)
const isprod = process.env.node_env ====='prod'prod'
这是我的amplify.yaml
version: 1
frontend:
phases:
# IMPORTANT - Please verify your build commands
build:
# commands: []
commands:
npm run build:$BUILD_ENV
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: /docs
files:
- '**/*'
cache:
paths: []
我尝试仅将产品应用于主人。我只希望使用产品模式并为主人运行。当我运行构建时,开发分支显示未启动的HTML,生产也是如此。它正在工作和构建,但是产品模式没有反映在生产中,因此它不会执行我的build prod命令。
我在线搜索并应用了环境变量,并遵循了此文档,该文档显示了构建过程“ https://docs.aws.amazon.com/amplify/latest/userguide/userguide/build-settings.html”如下:
仍然不起作用。
I am using AWS Amplify with the following configuration:
- https://dev.example.com/ - AWS Amplify - branch = dev
- https://example.com/ - AWS Amplify - branch = master
In gulpfile.js
I have rules applied for production (minification etc using)
const isProd = process.env.NODE_ENV === 'prod'
This is my amplify.yaml
version: 1
frontend:
phases:
# IMPORTANT - Please verify your build commands
build:
# commands: []
commands:
npm run build:$BUILD_ENV
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: /docs
files:
- '**/*'
cache:
paths: []
I tried applying prod to ONLY master. I only want the prod mode to be applied and ran for the master. When I run the build.. dev branches shows unminified HTML and so does production. It is working and building but the prod mode is not being reflected in production so it is not executing my build prod command.
I searched online and also applied Environment variables AND followed this documentation which shows the build process "https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html" as follows:
Still is not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了类似的问题。我不确定这是最优雅的解决方案:
这对我使用,尽管我的堆栈与您的堆栈不同。它可能会导致您朝着正确的方向前进,或者帮助他人。
I ran into a similar problem. I'm not sure this is the most elegant solution:
This worked for me using, though my stack is different than yours. It might lead you in the right direction, or help others.