I'm trying to work out what the correct process for deploying a nodejs application to a production environment should me, using webpack.
If this was a standard Java/Maven project I might do something like:
mvn clean install -Pdeploy-production
where the mvn install
compiles the application, and the additional deploy-production
profile uses a maven plugin to deploy it to our production environment and do whatever else.
I've been looking at tutorials like this one, or this one.
In the first tutorial, he suggests something like this:
"script": {
"start": "babel-node server-es6.js"
"build:server": "babel server-es6.js --out-file server.js"
"build:client": "webpack -p --config webpack.prod.config.js --progress"
}
Where essentially he provides two build scripts, and then a command to start the server running.
However, this doesn't explain how I actually get the code on to the production server and start it running.
As far as I see I have two options:
- On the production environment checkout the source code, and run the build scripts there and start a node process.
- Run the production build scripts in my development environment and SCP the dist folder to the production environment, and start a process there.
Can you point me in the right direction about what the best way to do this is?