Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-import-npm

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-import-npm

Import files from npm packages into your cordova www directory automatically, upon cordova prepare or cordova build

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
62
increased by287.5%
Maintainers
1
Weekly downloads
 
Created
Source

On development, don't use this yet...

cordova-import-npm

Import files from npm packages into your cordova www directory automatically, upon cordova prepare or cordova build

Oftentimes we want to import files available in npm modules into our www/ directory in cordova projects.

Install

Just run in the root directory of your cordova project

npm i cordova-import-npm

It will add a hook at your hooks directory (if you have none defined in config.xml it will use hooks/) and edit your config.xml accordingly, such that npm files that you set will be imported upon cordova prepare or cordova build

Settings

You define the npm files you'd like to import by editing the file npmFilesToImport.json. The syntax is the following:

{
  "npmPackageName": {
    "from": "path/to/file/relative/to/npmModule/directory",
    "to": "path/to/file/relative/to/cordovaWWW/directory"
  }
}

The paths may be strings or arrays, though arrays are recommended as then it works in either unix or windows file systems. Use an array to copy more than one file for each package.

Example

Imagine you wanted the latest jquery and bootsrap files on your www/js/res/ and www/css/res/ directories. Just run

npm i cordova-import-npm
npm i jquery bootstrap

And then edit your npmFilesToImport.json with this info:

{
  "jquery": {
    "from": ["dist", "jquery.min.js"],
    "to": ["js", "res", "jquery.min.js"]
  },
  "bootstrap": [
    {
      "from": ["dist", "js", "bootstrap.min.js"],
      "to": ["js", "res", "bootstrap.min.js"]
    },
    {
      "from": ["dist", "css", "bootstrap.min.css"],
      "to": ["css", "res", "bootstrap.min.css"]
    },
  ],
}

Then run cordova prepare or cordova build and the npm files will be copied before anything else is processed.

Keywords

FAQs

Package last updated on 01 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc