This guide provides instructions for contributing to this Capacitor plugin.
-
Fork and clone the repo.
-
Install the dependencies.
npm install
-
Install SwiftLint if you're on macOS.
brew install swiftlint
Build the plugin web assets and generate plugin API documentation using @capacitor/docgen
.
It will compile the TypeScript code from src/
into ESM JavaScript in dist/esm/
. These files are used in apps with bundlers when your plugin is imported.
Then, Rollup will bundle the code into a single file at dist/plugin.js
. This file is used in apps without bundlers by including it as a script in index.html
.
Build and validate the web and native projects.
This is useful to run in CI to verify that the plugin builds for all platforms.
Check formatting and code quality, autoformat/autofix if possible.
This template is integrated with ESLint, Prettier, and SwiftLint. Using these tools is completely optional, but the Capacitor Community strives to have consistent code style and structure for easier cooperation.
There is a prepublishOnly
hook in package.json
which prepares the plugin before publishing, so all you need to do is run:
npm publish
Note: The
files
array inpackage.json
specifies which files get published. If you rename files/directories or add files elsewhere, you may need to update it.
Since Ionic is built on top of Angular, in example porject used an embedded mechanism for managing environment variables. The official doc is here.
- create folder
environments
insrc
folder. Ex:example-app/src/environments/environment.ts
- in
environment.ts
define all environments variables:
export const environment = {
IONIC_API_KEY: 'site-api-key',
IONIC_API_SECRET: 'site-api-secret',
IONIC_SITE_ID: 'site-identifier',
IONIC_QUEUE_ID: 'queue-identifier',
IONIC_REGION: 'beta',
IONIC_COMPANY_NAME: 'IonicCompany',
};
After environment variables are defined:
- open
example-app
folder - run
npm run build
- run
npx cap sync
To be sure that environment variables applied correctly please open public
folder and find index-#{some_hash}.js
file. If variables applied correctly your should see something like this:
- open platform folder
ios
orandroid
- open IDE
- run project