I have a simple React.js app that works 100% perfectly fine on my localhost.
e.g.
npm install
npm start
and the browser opens up on port 3000. works great!Now, I'm trying to get this app up to an Azure App Service (formally Azure Websites).
Because my code sits in a Git repo, I connected my Azure App Service/WebSite to a Git repo and KUDU kicks in, when a commit is pushed up. So the Git deployment webhook is working, but I don't think anything else.
This is my packages.json
file:
{
"name": "Test Website",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.8.5"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-router": "^3.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Notice the "build": "react-scripts build"
? I believe this is the command I need to run to actually build this app for production.
i.e. npm run build
So - how can I get Azure to do these two steps on a git commit/push?
npm install
npm run build
Do I need to setup anything special in my startup
file? I think the npm run build
throws all the newly created files into the \build
folder, so I'm assuming I'll need to setup the startup file to be build\index.html
?
You will need to create your own customised deployment script for Kudu. Luckily, there is a deployment script generator as part of the azure-cli
tooling.
More details are on the Kudu wiki: https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script