environment-badge
v1.3.1
Published
Add a visual "badge" indicator to differentiate QA environments from production.
Downloads
582
Keywords
Readme
It's easy to get disoriented when your application runs in multiple environments. This package checks the domain & adds a simple indicator to let you know when you're not on production. It looks for the following environments out of the box:
- Local development, at
localhost
or.test
domains. - Development environments, at
dev.
or*-dev.
subdomains. - QA environments, at
qa.
or*-qa.
subdomains. - Preview environments, at
preview.
or*-preview.
subdomains.
Usage
If you're building your application with Webpack, Create React App, or a similar tool, simply import this module:
require('environment-badge')();
For applications without a front-end build system, you can embed this script from unpkg:
<script
type="text/javascript"
src="https://unpkg.com/environment-badge@^1.0.0/dist/bundle.js"
></script>
Advanced Usage
You can customize what environments are checked for by providing an array. For example:
require('environment-badge')([
{
displayName: 'local',
host: /(^localhost$|\.test$)/,
},
{
displayName: 'staging',
host: /^([a-z0-9-]*-)?staging\./,
backgroundColor: '#000000',
foregroundColor: '#fcd116',
},
]);
License
© DoSomething.org. environment-badge is free software, and may be redistributed under the terms specified in the LICENSE file. The name and logo for DoSomething.org are trademarks of Do Something, Inc and may not be used without permission.