npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-cli-plugin-cordova-v2

v2.5.1

Published

vue-cli 3.x plugin for Apache Cordova

Downloads

32

Readme

FORK OF https://github.com/m0dch3n/vue-cli-plugin-cordova

vue-cli-plugin-cordova

Vue CLI 3.x plugin for Apache Cordova.

Integrate Cordova into Vue Cli App

What is the difference with the basic version?

  • There are two additional commands to emulate the application on android or iOs.
  • It is possible to pass additional arguments to the commands-line

How To

Create Vue App

$ npm install -g @vue/cli
$ vue create my-app
$ cd my-app
$ npm install -g cordova # If cordova is not already installed 

Add the plugin to your vue app.

$ vue add cordova

Usage

Prepare

$ npm run cordova-prepare # prepare for build (you can run this command, when you checkouted your project from GIT, it's like npm install)

Android

$ npm run cordova-serve-android # Development Android
$ npm run cordova-build-android # Build Android
$ npm run cordova-run-android # Build Android and run into Emulator
$ npm run cordova-build-only-www-android # Build only files to src-cordova

IOS

$ npm run cordova-serve-ios # Development IOS
$ npm run cordova-build-ios # Build IOS
$ npm run cordova-run-ios # Build IOS and run into Emulator
$ npm run cordova-build-only-www-ios # Build only files to src-cordova

OSX

$ npm run cordova-serve-osx # Development OSX
$ npm run cordova-build-osx # Build OSX
$ npm run cordova-build-only-www-osx # Build only files to src-cordova

Browser

$ npm run cordova-serve-browser # Development Browser
$ npm run cordova-build-browser # Build Browser
$ npm run cordova-build-only-www-browser # Build only files to src-cordova

Electron

$ npm run cordova-serve-electron # Development Electron
$ npm run cordova-build-electron # Build Electron
$ npm run cordova-build-only-www-electron # Build only files to src-cordova

You can also pass additional arguments to command-line, each argument with spaced by "--" and news arguments beginning by --argument.

$ npm run cordova-build-android --extra-args='--jvmargs=-Xmx2048m --add-opens java.base/java.io=ALL-UNNAMED -- --packageType=apk' # Build Android with additional arguments

IMPORTANT

  • Path rewriting etc does not work under Cordova, that's why it's important to use router 'hash' mode, if you run or build for Cordova. history mode does not work! The plugin already tries to fix this automatically...

  • Assets and Scripts in vue's public folder need to have a dynamic path, because depending on dev or production build, you have different bases. In dev it's normally '/' and in production it's 'file:///android_asset/www/'. In other words, if you have i.e. an image under 'public/images/me.jpg', the relative url would be img='images/me.jpg'

  • You need some experience with Cordova, to solve many issues, like having the right Java JDK, Android SDK, XTools, Signing an App, Publishing an App etc. If you encounter issues related to Cordova etc, please don't post them this issue tracker.

  • If you are upgrading from an older release, please add <hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" /> to your config.xml

  • The devserver will run under https from now on, so make sure your rest & api endpoints are available under https, and have a correct CORS setup

What is the plugin doing ?

During installation

During installation, the plugin is setting some important variables, modifying the router mode and executing some cordova commands.

  • Setting baseUrl in vue.config.js to '' because in cordova production, files are served from file://android_asset/www/
  • Setting cordovaPath in vue.config.js
  • Checking if router is available and modify router mode to 'hash' if process.env.CORDOVA_PLATFORM is set
  • Adding ignore paths for cordova in .gitignore
  • Executing 'cordova create cordovaPath id appName' (cordovaPath, id and appName will be prompted)
  • Adding cordova before_prepare hook in config.xml
  • Executing 'cordova platform add platform' (platform will be prompted)

In development mode

In development mode (npm run cordova-serve-*), the plugin is starting the dev server, and creating an app with a webview, showing your dev server page.

It is doing this by:

  • Adding cordova.js to your index.html
  • Defining process.env.CORDOVA_PLATFORM to android, ios, osx, browser or electron
  • Starting the Dev Server
  • Executing 'cordova clean'
  • Executing 'cordova run platform'
  • Pointing the cordova config.xml to Dev Server in hook

In Production mode

In production mode (npm run cordova-build-*), the plugin is building the app, with all it's assets and files etc locally in the package. The webview is showing file:///android_asset/www/index.html

It is doing this by:

  • Adding cordova.js to your index.html
  • Defining process.env.CORDOVA_PLATFORM to android, ios, osx, browser or electron
  • Building the app, output to /src-cordova/www
  • Executing 'cordova clean'
  • Executing 'cordova build platform --release'

Please note

  • For a production build, you need to manually sign the app, in order to be able to install it on your device, or publish it in the app store.
  • You need to handle cordova's "deviceready" etc in your app
  • Cordova Plugins can be added under /src-cordova by executing 'cordova plugin add PLUGIN'
  • If you want to debug your build app, using chrome devtools, build your app with 'cordova build platform --debug' and make sure /src-cordova/www has your latest build by running cordova-build-only-www-platform

License

MIT

Credits

Credits go to

  • @dekimasoon https://github.com/dekimasoon/vue-cli-plugin-cordova
  • @quasarframework https://github.com/quasarframework/quasar-cli

Because my approach for this plugin, was inspired by theirs!