rollup-plugin-variables
v0.1.1
Published
Rollup plugin for parse variables
Downloads
117
Readme
Rollup Plugin Variables
Rollup plugin for parse variables
Install
npm install rollup-plugin-variables
or
yarn add rollup-plugin-variables
Usage
env.js
module.exports = () => {
return {
URL: 'http://www.example.com'
};
};
rollup.config.js
import variables from 'rollup-plugin-variables';
export default {
plugins: [variables()]
};
How will the result be?
before in Link.jsx
import React from 'react';
const LinkComponent = () => <a href="[[URL]]">Link</a>;
export default LinkComponent;
after in Link.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
export default {
plugins: [variables({ fileName: 'environments.js' })]
};
Function
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
export default {
plugins: [variables({ format: 'js' })]
};
Function
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
export default {
plugins: [variables({ marker: '{{}}' })]
};
Function
export default {
plugins: [
variables({
marker: () => {
if (process.env.NODE_ENV === 'development') {
return '{{}}';
}
return '[[]]';
}
})
]
};
NPM Statistics
Download stats for this NPM package
License
Rollup Plugin Variables is open source software licensed as MIT.