@thoughtsunificator/rollup-plugin-window-env
v1.0.12
Published
rollup plugin to inject given environment variables into the window object.
Downloads
69
Readme
rollup-window-env
rollup plugin to inject given environment variables into the window object..
Getting started
Installing
npm install @thoughtsunificator/rollup-plugin-window-env --save-dev
How does it work?
rollup-plugin-window-env will create a new object from the config file, env file and process.env
.
Order of priority:
- process.env
- env file
- config file
Usage
import configWindowEnv from '@thoughtsunificator/rollup-plugin-window-env'
export default {
plugins: [
configWindowEnv({ envPath: ".env.json", configPath: "data/config.json" })
]
}
data/config.json
{
"SITE_NAME": "FOO"
}
.env.json
{
"SITE_NAME": "BAR"
}
Within the context of your application:
console.log(window.SITE_NAME)
/* outputs:
{
SITE_NAME: "BAR"
}
*/