-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ed6f81
commit e75ef50
Showing
4 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Environment Plugin | ||
|
||
Pass environment variables to app with [`dotenv`](https://github.com/motdotla/dotenv) and custom variables | ||
|
||
## Install | ||
|
||
``` | ||
npm install -D @rambler-tech/razzle-environment | ||
``` | ||
|
||
or | ||
|
||
``` | ||
yarn add -D @rambler-tech/razzle-environment | ||
``` | ||
|
||
## Usage | ||
|
||
Add the plugin to `razzle.config.js` | ||
|
||
```js | ||
const EnvironmentPlugin = require('@rambler-tech/razzle-environment') | ||
|
||
const VERSION = '...' | ||
|
||
module.exports = { | ||
plugins: [ | ||
EnvironmentPlugin({ | ||
VERSION | ||
}) | ||
], | ||
modifyWebpackConfig({webpackConfig}) { | ||
// ... | ||
return webpackConfig | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require('dotenv').config() | ||
|
||
const webpack = require('webpack') | ||
const DotenvPlugin = require('dotenv-webpack') | ||
|
||
module.exports = (variables) => ({ | ||
modifyWebpackConfig({webpackConfig}) { | ||
webpackConfig.plugins = [ | ||
...webpackConfig.plugins, | ||
new webpack.EnvironmentPlugin(variables), | ||
new DotenvPlugin({ | ||
systemvars: true | ||
}) | ||
] | ||
|
||
return webpackConfig | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@rambler-tech/razzle-environment", | ||
"version": "0.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"dotenv": "^16.3.1", | ||
"dotenv-webpack": "^8.0.1" | ||
}, | ||
"peerDependencies": { | ||
"razzle": ">=4", | ||
"webpack": ">=5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters