Search code examples
javascriptangularangular2-cli

Who is the #each scripts.polyfills coming from?


I have generated a angular 2 application with the angular 2 CLI.

In the index.html file is stuff like:

{{#each scripts.polyfills}}
    <script src="Application/{{.}}"></script>
{{/each}}

When the application is build with the CLI command 'ng build' the output of index.html is:

<script src="Application/vendor/scripts1.js"></script>
<script src="Application/vendor/scripts2.js"></script>
<script src="Application/vendor/scripts3.js"></script>

Now I ask you where is that #each comming from means what language/library?

and

where is the scripts.polyfills object defined in my CLI created angular 2 app.

I can not find any folder/variable with name 'scripts' anywhere.


Solution

  • The polyfills are inbuilt into the angular-cli tool. Polyfill for angular

    In the linked page search for options.polyfills. If you want to include other polyfills, the option would be to include it in angular-cli-build.js. For example , to include jquery as a polyfill add the polyfills tags besides vendorNPM files :-

     vendorNpmFiles: [
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',
      'zone.js/dist/**/*.+(js|js.map)',
      'es6-shim/es6-shim.js',
      'reflect-metadata/**/*.+(ts|js|js.map)',
      'rxjs/**/*.+(js|js.map)',
      '@angular/**/*.+(js|js.map)',
      'jquery/**/*.js'
    ],
    polyfills:[
       'vendor/jquery/dist/jquery.min.js', 
       'vendor/es6-shim/es6-shim.js',
        'vendor/reflect-metadata/Reflect.js',
        'vendor/systemjs/dist/system.src.js',
        'vendor/zone.js/dist/zone.js', 
    ]