[英]How to run multiple commands in a single package.json line with configuration
I want to run the to build commands (clienr and server) in one npm run commands.我想在一个 npm 运行命令中运行构建命令(客户端和服务器)。 So on my package.json scripts section I added this line:
所以在我的 package.json 脚本部分我添加了这一行:
"build-all": "ng build --prod && ng run web-app:server",
The problem occurs when I run this commands: npm run build-all --configuration=qa.europe.当我运行以下命令时出现问题:npm run build-all --configuration=qa.europe。
The configuration is loaded when I run each commands separately but not when I run the above commands.单独运行每个命令时会加载配置,但运行上述命令时不会加载配置。
Any ideas?有任何想法吗?
You can try to use postinstall, it will look as next:您可以尝试使用 postinstall,它将如下所示:
"scripts": {
"start": "ng run web-app:server",
"postinstall": "ng build --prod --configuration=qa.europe",
}
So after npm install, the build of your UI starts.所以在 npm 安装之后,你的 UI 的构建就开始了。 And after that will start your server.
之后将启动您的服务器。
You can try this.你可以试试这个。
"scripts": {
"start:production": "npm install && npm run build && npm run start:prod",
"start:prod": "cross-env NODE_ENV=production node server",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
npm run start:production it will run "start:production" & "start:prod" both scripts npm run start:production 它将运行“start:production”和“start:prod”这两个脚本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.