I'm creating an Ionic project using Capacitor (edit: the newer recommended framework compared to Cordova) and added Android as a target.
I've been able to build the app and add the Android target, which creates a bucketload of files under android/
, using:
ionic build
ionic cap add android
Then, I was able to launch Android Studio and emulate my app, using npx cap open android
, with "Run App" in Android Studio. This added a few more bucketloads of files.
I was able to get most of them to be ignored by adding the "ionic" and "AndroidStudio" gitignore entries from gitignore.io, but if someone clones the repo, they can rebuild the entire Android directory from scratch, right? Do I just consider everything in the android folder to be a build artifact that can be recreated from the core ionic project using capacitor (i.e. "cap").
Is there anything that needs to be saved to the repo in the ionic android directory? If so, which files - or should I fall back to ionic/Android Studio gitignore entries for the android folder?
Is there anything that needs to be saved to the repo in the ionic android directory?
I would suggest that you include your native folders in your repo as well.
Based on my experience with capacitor over the past year while developing two applications, consider these things.
but if someone clones the repo, they can rebuild the entire Android directory from scratch, right?
When your application grows, depending on its intended functionality, this would not be an easy task. They will have to go through all these minor tweaks to get it working.
All in all, put your native code in the repo as well. For me, the repository size with the native codes is not terribly huge.
In Capacitor you are supposed to commit the ios
and android
folders. They contain their own .gitignore
files with the recommended files for iOS and Android.
They are not build artifacts, if you change icons or configurations (in Info.plist, AndroidManifest.xml, etc) and you delete the folders, those changes will be lost.
If you clone a Capacitor project you should run this commands:
npm install (or other install package depending on your package manager)
npm run build (or ionic build if using ionic)
npx cap sync (this copies files and generates non committed files)
As @jcesarmobile
In Capacitor you are supposed to commit the ios and android folders. They contain their own .gitignore files with the recommended files for iOS and Android.
But if you're looking for a .gitignore
to use at the root of your project, this one should do the job.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.vscode
.idea
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Optional eslint cache
.eslintcache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With