1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular 17 build chunks - post build scripts, alter HTML

Discussão em 'Angular' iniciado por user24670032, Setembro 24, 2024.

  1. user24670032

    user24670032 Guest

    I have made new angular project in v17.3.0 - SSR mode enabled. Below is the image of ng build output build output

    I can see in index.html , that 3 chunks are added with modulepreload (chunks in Initial Chunk files)

    <link rel="modulepreload" href="chunk-KFDVPRYR.js"><link rel="modulepreload" href="chunk-WFAJ4VF6.js"><link rel="modulepreload" href="chunk-LDGDJR6O.js">


    network tab resources load I want to understand what these 3 files are for. Now, i want to remove the modulepreload option to increase my LCP. Currently i am preloading my images, but its still being fetched after these 3 scripts are done loading. So, i wrote a post build script and moved all my preload links(eg. ) before all the links(rel="modulepreload"). The issue is after page load its giving error: Error: NG0507(https://angular.io/errors/NG0507). The content was altered as in the position of links tag are moved. How to resolve this issue. Can some one please guide me on this.

    What i expect to happen is , my preload links should execute first than the chunks preloadmodule

    Latest Update: Based on this https://github.com/angular/angular-cli/pull/27581 , we can remove the preloadmodule chunks from angular.json. we have to add preloadInitial as false. After adding its working how i want. Its resolved. "index": { "input": "src/index.html", "preloadInitial": false }

    Continue reading...

Compartilhe esta Página