You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package includes a webpack plugin used by [Create React App](https://github.com/facebookincubator/create-react-app).
4
+
The plugin grabs environment variables that follows a specified regex and injects them into the application using the
5
+
webpack DefinePlugin.
6
+
In addition, the plugin allows defining custom environment variables to be injected.
7
+
8
+
## Usage in Create React App Projects
9
+
10
+
See [webpack.config.dev.js](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.dev.js#L200) and [webpack.config.prod.js](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.prod.js#L234).
11
+
12
+
## Usage Outside of Create React App
13
+
14
+
If you want to use this webpack plugin in a project not built with Create React App, you can install it with following steps.
15
+
16
+
First, install this package.
17
+
18
+
```
19
+
npm install --save-dev webpack-env-define-plugin
20
+
```
21
+
22
+
Then reference it in your webpack config:
23
+
24
+
```js
25
+
var EnvDefinePlugin =require('../../webpack-env-define-plugin');
26
+
```
27
+
28
+
and define it as a plugin in the webpack config plugin section:
29
+
30
+
```js
31
+
plugins: [
32
+
...
33
+
newEnvDefinePlugin({
34
+
// Grab MY_PREFIX_* environment variables
35
+
regex:/^MY_PREFIX_/i,
36
+
customVariables: {
37
+
// Useful for determining whether we’re running in production mode.
38
+
// Most importantly, it switches React into the correct mode.
0 commit comments