angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Improve ng build --localize argument to accept locales instead of a boolean

Open kbarendrecht opened this issue 5 years ago • 4 comments

🚀 feature request

Relevant Package

This feature request is for @angular/cli and possibly @angular/compiler-cli @angular/compiler @angular/localize.

Description

The --localize argument for the ng build command currenty only accepts true or false which sets the locales from predefined configurations in the angular.json file.

Describe the solution you'd like

Allow to set one or multiple locales through ng build --localize=en ng build --localize=en,fr.

Describe alternatives you've considered

The alternatives I found are;

  • predefining each locale (and locale combination !) as a different configuration.
  • building every locale

I believe both these alternatives do not fully benefit from the merits of the new faster way of making multiple localized builds.

kbarendrecht avatar Nov 30 '20 12:11 kbarendrecht

Transferring to CLI project...

petebacondarwin avatar Nov 30 '20 12:11 petebacondarwin

This is already possible.

https://github.com/angular/angular-cli/blob/1f42e071b4ae3ddee8b2eee1d27e8b6ad41e0cb0/packages/angular_devkit/build_angular/src/browser/schema.json#L212

alan-agius4 avatar Nov 30 '20 13:11 alan-agius4

@alan-agius4 , I'm receiving the following error. Perhaps I've made a mistake?

root:/[omitted]/resources/script [13:20]> yarn ng build --localize=fr
yarn run v1.22.5
$ /[omitted]/resources/script/node_modules/.bin/ng build --localize=fr
Cannot parse arguments. See below for the reasons.
    Argument --localize could not be parsed using value "fr".Valid type(s) is: boolean
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

deps;

 "dependencies": {
    "@angular/animations": "^11.0.2",
    "@angular/cdk": "^11.0.1",
    "@angular/cli": "^11.0.2",
    "@angular/common": "^11.0.2",
    "@angular/compiler": "^11.0.2",
    "@angular/core": "^11.0.2",
    "@angular/forms": "^11.0.2",
    "@angular/localize": "^11.0.2",
    "@angular/material": "^11.0.1",
    "@angular/material-moment-adapter": "^11.0.1",
    "@angular/platform-browser": "^11.0.2",
    "@angular/platform-browser-dynamic": "^11.0.2",
    "@angular/router": "^11.0.2",

kbarendrecht avatar Nov 30 '20 13:11 kbarendrecht

It looks like passing a non boolean is not working as expected when used via the CLI, but it does work when set in angular.json.

As a workaround you can use something like;

"configurations": {
  "fr-de": {
    "localize": ["fr", "de"]
  },
  "production": {
    "fileReplacements": [
      {
        "replace": "src/environments/environment.ts",
        "with": "src/environments/environment.prod.ts"
      }
    ],
    "optimization": true,
    "outputHashing": "all",
    "sourceMap": false,
    "extractCss": true,
    "namedChunks": false,
    "extractLicenses": true,
    "vendorChunk": false,
    "buildOptimizer": true,
    "budgets": [
      {
        "type": "initial",
        "maximumWarning": "2mb",
        "maximumError": "5mb"
      },
      {
        "type": "anyComponentStyle",
        "maximumWarning": "6kb",
        "maximumError": "10kb"
      }
    ]
  }
}

Which you can then execute using ng build --configuration=production fr-de

alan-agius4 avatar Nov 30 '20 14:11 alan-agius4

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

alan-agius4 avatar Dec 05 '23 13:12 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.