diff --git a/README.md b/README.md index c53ad6b17..aa2f13e22 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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