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

feature(environment configuration) #1471

Merged
merged 2 commits into from
Aug 24, 2018
Merged

feature(environment configuration) #1471

merged 2 commits into from
Aug 24, 2018

Conversation

nphyatt
Copy link
Contributor

@nphyatt nphyatt commented Aug 23, 2018

Add support for using process.env.MY_VAR syntax in app code

Short description of what this resolves:

Allow for customization of bundled application code based on environment configuration files and environment variables. This enables better support for customization using CI/CD tools.

Changes proposed in this pull request:

By adding the DotEnv webpack plugin to the webpack config users can now add Node style process.env.MY_VAR style syntax directly into their typescript and when the application is bundled it'll be replaced with the following order of precedence.

  • If the variable exists in the process environment it will be that value.
  • If the variable is not defined in the process environment it will be read from a .env.dev file for dev builds or .env.prod file for prod builds which are located in the root of the app
  • If the variable is not defined in either place it will be undefined

In order to take advantage of this we should update the starters and have users with existing apps add a src/declarations.d.ts file with the following declaration

declare var process: { env: { [key: string]: string | undefined; } };

Fixes: #

@imhoffd
Copy link
Contributor

imhoffd commented Aug 24, 2018

Looks great! Tested!

@imhoffd
Copy link
Contributor

imhoffd commented Aug 24, 2018

PR for starters: ionic-team/starters#420

@imhoffd imhoffd merged commit 53fc341 into master Aug 24, 2018
@imhoffd imhoffd deleted the feat-env-var-config branch August 24, 2018 19:18
trsrm added a commit to powwowinc/ionic-app-scripts-tiny that referenced this pull request Jan 2, 2019
3.1.9:
* fix(2889): fix build error with --prod
* fix(serve): start listening when watch is ready
* fix(live-server): update android platform path (ionic-team#1407)
* docs(changelog): 3.1.9

3.1.10:
* Update node-sass dependency (ionic-team#1435)
Updating node-sass dependency from 4.7.2 to 4.9.0 to make it works with node 10 on windows (build fail with ionic start)
* chore(package): bump deps (ionic-team#1421)
* chore(deps): no package lock
* chore(changelog): 3.1.10

3.1.11:
* fix(serve): fix EADDRINUSE issue with dev logger server
fixes ionic-team/ionic-cli#3368
fixes ionic-team/ionic-cli#1678
fixes ionic-team/ionic-cli#1830
fixes ionic-team/ionic-cli#1721
fixes ionic-team/ionic-cli#1866
fixes ionic-team/ionic-cli#1808
fixes ionic-team/ionic-cli#3022
* docs(changelog): 3.1.11 changes

3.2.0:
* feat(environments): configuration via process.env.VAR replacement (ionic-team#1471)
* fix(sass): remove PostCSS warning (ionic-team#1364)
This removes following warning:
Remove warning: Without `from` option PostCSS could generate wrong source map or do not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning
`from: the input file name (most runners set it automatically).`
Source: https://github.com/postcss/postcss
Fixes ionic-team#1359 #13763
ionic-team#1359
ionic-team/ionic-framework#13763
* fix(serve): use wss protocol for secure websocket when page is using https (ionic-team#1358)
* docs(changelog): 3.2.0

3.2.1:
* docs(readme): add note about existing declaration
addresses ionic-team/ionic-cli#3541
* chore(deps): update webpack to 3.12.0 (ionic-team#1477)
* chore(deps): bump node-sass to 4.9.3 to fix security warnings (ionic-team#1483)
* chore(deps): bump node-sass to 4.10.0 to fix security warnings (ionic-team#1493)
* docs(changelog): 3.2.1
@prakasa-tkpd
Copy link

anyone can share .env value example... Im so confused to filling the value of .env. Need help here

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

Successfully merging this pull request may close these issues.

5 participants