This guide will demonstrate how to integrate Aurelia 2 with Cordova/PhoneGap for mobile application development.
Ensure you have the following installed:
Node.js and npm
Cordova CLI: npm install -g cordova
Start by creating a new Cordova project:
Add the platforms you are targeting:
Navigate to the www
directory, which Cordova uses for the web application content. You'll want to clear its contents, as we will generate the Aurelia 2 app directly in this directory.
Now, use npx makes aurelia
with the --here
flag to create a new Aurelia 2 project in the current directory without creating an additional folder:
Configure your Aurelia 2 build process to output the files directly into the www
directory. If you are using the default setup with Webpack, you may not need to change anything, as it already outputs to a dist
folder inside the current directory. However, review your configuration to ensure it aligns with Cordova's structure.
Build your Aurelia 2 application. The build process should place the output into the www
directory.
After building your Aurelia application, navigate back to the root directory of your Cordova project. You can now build the Cordova app:
Run your application on an emulator or a connected device with the following command:
You now have an Aurelia 2 application packaged within a Cordova application, ready for mobile deployment. Be sure to utilize Cordova plugins to access native device features and thoroughly test on different devices for performance and user experience.