aurelia / aurelia/cli

[RFC] Better way of handling environment files (config files)

Open
#1,039 2 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
402
Forks
134
PR merge metrics
No merged PRs in 30d

Description

# 💬 RFC
I want to talk about handling variable that are `environment` specific in aurelia.

the way that we handle it now, is by having multiple `json` files in an `environment` folder,
when we start a build process - one of those files is copied into the `src` folder, and gets bundled with the rest of the app.
you can dictate witch file is copied by specifying the "--env" flag while building.

in those files, you can put whatever you want - so it's an easy way to have `variables` that differ between environments.

I see 2 different kind of variables that can go into those config files.
1. **build time variables:** variables that affect the build - (e.g minifying the code, enabling/disabling logging, enabling/disabling sourcemap etc.).
_setting different values in those variables should result in different build output._
2. **run time variables:** variable that affect the application - (e.g api url endpoints, api keys, ticket duration etc)
_setting different values in those variables should not affect the build output._
one may change those values even **after** the build and expect the app to consider the new values.
this is currently cannot be done because the config file is bundled along with the application.
any change to the config must also come with a new build.

the current way of handling config files has another problems/limitations:
1. it's annoying to have a file in the `src` folder - that should not be committed into the source control.
2. TFS adds `readlony` attributes to all the files that he manages - so copying one of the config files work only once, the next time you try to build - the file cannot be overwritten because of the `readonly` flag. https://github.com/aurelia/cli/issues/1031

what can we do about this?
how does other framework handle config files?
can we have 2 sort of configs? one for build time variables? and another for run time variables?
can we even have files that are left outside of the bundle for easy editing?
can we skip the part where we copy the file into `src`?

Contributor guide

Open the contributing guide

Research direction

Start by tracing the CLI build flow around the --env flag, the environment folder, and the copy into src. Review issue #1031 for the readonly-file constraint, then compare how build-time and runtime values would affect bundling. Done would require an agreed design for separating or externalizing these configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.