Skip to content

Commit

Permalink
docs: Adding small environment variables section to readme (#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian authored Jan 14, 2021
1 parent df48437 commit 4acc8c7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,22 @@ The default templates comes with a `.css` file for each component. You can start
- `npm install --save-dev less less-loader` (inside your preact application folder)
- start replacing `.css` files with `.less` files

### Using Environment Variables

You can reference and use environment variables in your `preact.config.js` by using `process.env`:

```js
export default {
webpack(config, env, helpers, options) {
if (process.env.MY_VARIABLE) {
/** You can add a config here that will only used when your variable is truthy **/
}
},
};
```

If you'd like to use these variables in your application, you can use the [DefinePlugin] config from our recipes wiki.

[promise]: https://npm.im/promise-polyfill
[fetch]: https://github.com/developit/unfetch
[preact]: https://github.com/preactjs/preact
Expand Down Expand Up @@ -366,6 +382,7 @@ The default templates comes with a `.css` file for each component. You can start
[`async!`]: https://github.com/preactjs/preact-cli/blob/1.4.1/examples/full/src/components/app.js#L7
[sass]: https://sass-lang.com
[less]: http://lesscss.org
[defineplugin]: https://github.com/preactjs/preact-cli/wiki/Config-Recipes#use-environment-variables-in-your-application

### Route-Based Code Splitting

Expand Down

0 comments on commit 4acc8c7

Please sign in to comment.