angular / angular/angular-cli

Support multiple environments in the same build

Offen
#3,855 65 Kommentare 65 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: @angular-devkit/build-angular area: docs devkit/build-angular:browser freq3: high severity2: inconvenient type: faq type: RFC / discussion / question
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
14 Std. 23 Min.
Gemergte PRs (30 T.)
162

Beschreibung

> Please provide us with the following information:
> ---------------------------------------------------------------

### OS?
> Mac OSX (Sierra)

### Versions.
```
angular-cli: 1.0.0-beta.24
node: 6.9.2
os: darwin x64
@angular/common: 2.4.1
@angular/compiler: 2.4.1
@angular/core: 2.4.1
@angular/forms: 2.4.1
@angular/http: 2.4.1
@angular/platform-browser: 2.4.1
@angular/platform-browser-dynamic: 2.4.1
@angular/router: 3.4.1
@angular/compiler-cli: 2.4.1
```

### This is a feature request

I started internationalizing my application, and I met the following problem: when generating the bundle for the French locale (for example), I should include the locale-specific fr.js script of moment.js. Other libraries could also provide locale-specific JS files, or could need code that is specific to that locale (to internationalize a datepicker, for example).

I think the best way to do that would be to create an 'fr' environment file, simply containing

```
import 'moment/locale/fr.js';
```

and to use `--env fr`. Unfortunately, there doesn't seem to be a way to specify two different environments. And I wouldn't like to create a dev-fr environment, a prod-fr environment, a dev-en environment, a prod-en environment, etc.

Another use-case for that would be to create separate bundles for browsers, containing the polyfills that are needed for different browsers, and thus be able to generate a production bundle, for the French locale, and the chrome browser. I'm sure other use-cases could exist.

So I think it would be nice if angular-cli allowed specifying several environments. This is BTW a feature that exists in other build tools (like Maven profiles, or gradle properties, for example)

What do you think? Is there another nice way to achieve that?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der angular-cli-Behandlung der Option --env und dem Einstiegspunkt der Build-Konfiguration. Stelle die im Issue beschriebenen Anwendungsfälle für Locale und Browser-Profile nach und definiere anschließend, wie mehrere Umgebungen kombiniert werden sollen, ohne dass jedes Umgebungspaar separat deklariert werden muss.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
build-system, cli, internationalization
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.