3

we are upgrading from our AngularJS 1.6+Bower+Gulp to Angular4+AngularCLI and I seem to be unable to overcome the obstacle of replacing the strings in the html by the strings stored in some config.json file.

I came across this link https://github.com/angular/angular-cli/issues/4066 and it seems like angular-cli won't ever support this feature.

There are few interesting approaches similar to here How to insert a Build Number or Timestamp at build time in AngularCLI

But none of those solutions are quite suitable or easy to configure, as it seems the angular-cli doesn't allow to further configure the webpack by using any additional modules (so it seems).

To explain, imagine the following index.html part

<head>
    <title>AppName</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
    <link rel="shortcut icon" href="images/%ENVIRONMENT-FAVICON%">
    <link rel="apple-touch-icon" href="%APP_URL%/images/touch-icon.png">
    <link rel="apple-touch-icon" href="%APP_URL%/images/touch-icon-76x76.png" sizes="76x76">
    ...


    <base href="/">

  </head>
<body>
<script>
  // .. Google Analytics Code

  ga('create', '%GOOGLE_ANALYTICS_KEY%', 'auto');
</script>
</body>

As you can see, there are quite a few parameters that need to be injected before (or after) 'ng serve' builds the app in the memory and I wonder if anyone have ever done anything similar to what I'm after

Community
  • 1
  • 1
belzebu
  • 810
  • 7
  • 25

0 Answers0