Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Add ENV example #139

Open
samikeijonen opened this issue May 17, 2019 · 2 comments
Open

Add ENV example #139

samikeijonen opened this issue May 17, 2019 · 2 comments

Comments

@samikeijonen
Copy link
Contributor

samikeijonen commented May 17, 2019

The idea behind .env file is that we don't always have the same setup between developers, nor should we.

We could start with BrowserSync.

  • .env file itself is ignored from the repo.
  • Provide .env.example file which could look like this.
BROWSER_SYNC_HOST="localhost"
BROWSER_SYNC_PORT=3000
BROWSER_SYNC_PROXY="http://tenup-scaffold.test"
BROWSER_SYNC_OPEN=false

In webpack.settings.js file change to this:

host: process.env.BROWSER_SYNC_HOST || 'localhost',
port: process.env.BROWSER_SYNC_PORT || 3000,
proxy: process.env.BROWSER_SYNC_PROXY || 'http://tenup-scaffold.test',
open: process.env.BROWSER_SYNC_OPEN || false,

When developer wants to change default settings:

  • Copy .env.example file to as .env.
  • Change settings in .env for your environment.
  • For example change Proxy URL by setting BROWSER_SYNC_PROXY="https://my-url.test"
@emeaguiar
Copy link

+1 for this

I'm actually having issues understanding how to set up env variables and this could be very useful

@curtisbelt
Copy link

I propose an additional SITE_URL variable, and for proxy using

proxy: process.env.SITE_URL || process.env.BROWSER_SYNC_PROXY || 'http://tenup-scaffold.test',

This gives us a general-use URL while still allowing BROWSER_SYNC_PROXY to override. The reason is that this proxy URL is probably the same URL we want to use on pa11y.js.

https://github.com/10up/theme-scaffold/blob/master/package.json#L99-L105
https://github.com/10up/theme-scaffold/blob/master/tests/accessibility/compliance/pa11y.js#L8

The URLs in package.json could be kept relative, and then have process.env.SITE_URL prepended when they are consumed in pa11y.js.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants