Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ExtendedDefinePlugin #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ module.exports = {

## 6. Feature flags

We have code we want to gate only to our dev environments (like logging) and our internal dogfooding servers (like unreleased features we're testing with employees). In your code, refer to magic globals:
We have code we want to gate only to our dev environments (like logging) and our internal dogfooding servers (like unreleased features we're testing with employees). In your code, refer to magic globals (you must `npm install extended-define-webpack-plugin`):

```js
if (__DEV__) {
Expand All @@ -155,10 +155,12 @@ Then teach webpack those magic globals:
```js
// webpack.config.js

// definePlugin takes raw strings and inserts them, so you can put strings of JS if you want.
var definePlugin = new webpack.DefinePlugin({
__DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')),
__PRERELEASE__: JSON.stringify(JSON.parse(process.env.BUILD_PRERELEASE || 'false'))
// ExtendedDefinePlugin is an extended version of webpack.definePlugin that takes raw strings and inserts them, so you can put strings of JS if you want.
var ExtendedDefinePlugin = require('extended-define-webpack-plugin');

var definePlugin = new ExtendedDefinePlugin({
__DEV__: JSON.parse(process.env.BUILD_DEV || 'true'),
__PRERELEASE__: JSON.parse(process.env.BUILD_PRERELEASE || 'false')
});

module.exports = {
Expand Down