https://github.com/andrelmlins/rollup-plugin-variables
Rollup plugin from parse variables
https://github.com/andrelmlins/rollup-plugin-variables
parser plugin rollup variables
Last synced: 8 months ago
JSON representation
Rollup plugin from parse variables
- Host: GitHub
- URL: https://github.com/andrelmlins/rollup-plugin-variables
- Owner: andrelmlins
- License: mit
- Created: 2020-03-09T17:59:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-09T19:14:36.000Z (over 6 years ago)
- Last Synced: 2025-10-05T20:46:50.780Z (9 months ago)
- Topics: parser, plugin, rollup, variables
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rollup Plugin Variables
Rollup plugin for parse variables
[](https://www.npmjs.com/package/rollup-plugin-variables) [](https://github.com/andrelmlins/rollup-plugin-variables/blob/master/LICENSE) [](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 = () => Link;
export default LinkComponent;
```
**after in Link.jsx**
```jsx
import React from 'react';
const LinkComponent = () => Link;
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|Function` 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
[](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).