The Build Process
The Git Workflow at the core of Ionic Pro takes commits of your app code, builds them in the cloud, and then makes it possible to distribute and manage those builds through a simple Dashboard interface and CLI tools.
A Build
in Ionic Pro is triggered when running git push ionic master
(or any other non-master branch) with new changes to your app. Each build goes through a CI system that triggers a full build of your app (we run npm run build
), and the completed build is stored for later use through one of the core Ionic Pro services.
Customizing your Builds
When you push code up to Ionic, we run npm run build
in the root directory of your repository. This means you have full control over the build process. By default, we recommend commiting the Ionic Project directory at the root level, which comes default with a package.json
file with the following:
{
...
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
...
}
npm run build
is controlled by the scripts: build
line which defaults to "build": "ionic-app-scripts build"
.
A common change people like to make is making sure that Ionic Pro builds with production output. To make this change, simply change the package.json
file to include the --prod
flag like so:
{
...
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build --prod",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
...
}
You could commit different package.json
files to different branches if you’d like different build setups run.
Using different Repository structures
If your repository includes the Ionic app as a sub-folder or a different special structure, you just need to make sure you set up npm run build
to perform the right actions. The requirements are:
npm install
needs to install the dependencies inside of your app directorynpm run build
needs to execute a build of your code when run from the root of your repository- A
www
built directory must exist at the root folder after performingnpm run build
For example, if we commited a repository where the Ionic app was actually located in path-to/your-app
, you could add a package.json
file at the root level of our repository with the following contents in order to achieve the 3 requirements from above:
{
"scripts": {
"install": "cd path-to/your-app && npm install",
"build": "cd path-to/your-app && ./node_modules/.bin/ionic-app-scripts build --prod --wwwDir ./../../www"
}
}
If you also require npm install
to run at the root directory, you can change the "install"
script to instead be "postInstall"
which will run both.