# cdnjs-env

> Use full / minified versions of CDNJS libraries based on the environment.

Latest version **1.0.0** (published 2017-05-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install cdnjs-env
pnpm add cdnjs-env
yarn add cdnjs-env
bun add cdnjs-env
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-05-04 |
| First published | 2017-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ion Suman |
| Maintainers | sumanion |

## Links

- npm: https://www.npmjs.com/package/cdnjs-env
- Repository: https://github.com/103058/cdnjs-env
- Homepage: https://github.com/103058/cdnjs-env#readme
- Issues: https://github.com/103058/cdnjs-env/issues
- npm.io page: https://npm.io/package/cdnjs-env

## Recent versions

- 1.0.0 (latest) — 2017-05-04

## README

# CDNJS ENV

Use full / minified versions of CDNJS libraries based on the environment.

## Installation

Using npm:

```bash
$ npm install cdnjs-env --save
```

Using yarn:

```bash
$ yarn add cdnjs-env
```

## Usage

Standalone:

```js
// Load the module.
const cdnjs = require('cdnjs-env')

// The desired library (jQuery).
let lib = 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js'

// Change env.
process.env.NODE_ENV = 'development'

// Returns the full version of the library (basically the same url).
cdnjs.url(lib) // https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js

// Change env.
process.env.NODE_ENV = 'production'

// Returns the minified version of the library.
cdnjs.url(lib) // https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js
```

In [ExpressJS](http://expressjs.com/):

```js
// Load the module.
const cdnjs = require('cdnjs-env')

// The Express app.
const app = express()

// Add the `cdnjs-env` functionality to the request.
app.use(cdnjs.middleware())

// Next, you should be able to use exposed method.
app.get('/', (req, res) => {

  // Get full or minified version of a library based on the environment.
  res.locals.cdnjs(lib)

  res.send('EOF')
})
```

## License

The MIT License (MIT)

Copyright (c) 2017 Ion Suman <sumanion122@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/cdnjs-env · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
