# rollup-plugin-variables

> Rollup plugin for parse variables

Latest version **0.1.1** (published 2020-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-variables
pnpm add rollup-plugin-variables
yarn add rollup-plugin-variables
bun add rollup-plugin-variables
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2020-03-09 |
| First published | 2020-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | André Lins |
| Maintainers | andrelmlins |
| Keywords | rollup, plugin, variables |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-variables
- Repository: https://github.com/andrelmlins/rollup-plugin-variables
- Issues: https://github.com/andrelmlins/rollup-plugin-variables/issues
- npm.io page: https://npm.io/package/rollup-plugin-variables

## Dependencies (1)

- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2020-03-09
- 0.1.0 — 2020-03-09

## README

# Rollup Plugin Variables

Rollup plugin for parse variables

[![npm version](https://badge.fury.io/js/rollup-plugin-variables.svg)](https://www.npmjs.com/package/rollup-plugin-variables) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/andrelmlins/rollup-plugin-variables/blob/master/LICENSE) [![Build Status](https://travis-ci.com/andrelmlins/rollup-plugin-variables.svg?branch=master)](https://travis-ci.com/andrelmlins/rollup-plugin-variables)

## Install

```
npm install rollup-plugin-variables
```

or

```
yarn add rollup-plugin-variables
```

## Usage

**env.js**

```js
module.exports = () => {
  return {
    URL: 'http://www.example.com'
  };
};
```

**rollup.config.js**

```js
import variables from 'rollup-plugin-variables';

export default {
  plugins: [variables()]
};
```

### How will the result be?

**before in Link.jsx**

```jsx
import React from 'react';

const LinkComponent = () => <a href="[[URL]]">Link</a>;

export default LinkComponent;
```

**after in Link.jsx**

```jsx
import React from 'react';

const LinkComponent = () => <a href="http://www.example.com">Link</a>;

export default LinkComponent;
```

## Options

### `fileName`

Type `String|Function` Default: `env.js`

**rollup.config.js**

#### `String`

```js
export default {
  plugins: [variables({ fileName: 'environments.js' })]
};
```

#### `Function`

```js
export default {
  plugins: [
    variables({
      fileName: () => {
        if (process.env.NODE_ENV === 'development') {
          return 'environments.test.js';
        }

        return 'environments.js';
      }
    })
  ]
};
```

### `format`

Type `String<js,json,txt>|Function<js,json,env>` Default: `js`

**rollup.config.js**

#### `String`

```js
export default {
  plugins: [variables({ format: 'js' })]
};
```

#### `Function`

```js
export default {
  plugins: [
    variables({
      format: () => {
        if (process.env.NODE_ENV === 'development') {
          return 'json';
        }

        return 'js';
      }
    })
  ]
};
```

### `marker`

Type `String|Function|Array` Default: `[[]]`

**rollup.config.js**

#### `String`

```js
export default {
  plugins: [variables({ marker: '{{}}' })]
};
```

#### `Function`

```js
export default {
  plugins: [
    variables({
      marker: () => {
        if (process.env.NODE_ENV === 'development') {
          return '{{}}';
        }

        return '[[]]';
      }
    })
  ]
};
```

## NPM Statistics

Download stats for this NPM package

[![NPM](https://nodei.co/npm/rollup-plugin-variables.png)](https://nodei.co/npm/rollup-plugin-variables/)

## License

Rollup Plugin Variables is open source software [licensed as MIT](https://github.com/andrelmlins/rollup-plugin-variables/blob/master/LICENSE).

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