💫 Merge a configuration file with environment variables.
The config-webpack-plugin
will intercept a JS configuration file during webpack's compilation time. The specified configuration file will be modified with any matching environment variables.
npm install config-webpack-plugin --save-dev
const ConfigPlugin = require('config-webpack-plugin');
module.exports = {
// ...
plugins: [
new ConfigPlugin('./config')
]
// ...
}
That's it! The first and unique parameter is a string containing the relative path of the configuration file you want for config-webpack-plugin
to intercept.
Currently, config-webpack-plugin
support a simple type of JS configuration file that export an object where key-value pairs represents key-value configurations:
module.exports = {
API_BASE_URL: 'http://localhost/',
NODE_ENV: 'development',
AUTH_SPOOFED: true,
}
If you want to collaborate with the development of config-webpack-plugin
you need to have installed NodeJS 6 and Gulp. Then follow these instructions to make my life easier:
- Fork this repo.
- Clone your forked repo.
- Create a feature branch with:
git checkout -b feature/<name-of-feature>
. - Create a pull request to be merged into
develop
branch.
💁 Please, do not submit PR to be merged into
master
branch.
- Add test. Please!
- Add CI. Please!
- Support multiple file (
new ConfigPlugin(['./config.default.js', '.config.local.js'])
). - Support JSON file too
♥️ , because they are prettiest for configuration.
💁 Do you want to suggest a feature? ➕ Add a suggestion.