0

I have this @angular/elements project for which after each build I have to concat all generated file into a single bundle. Something like this

$> ng build els --prod --output-hashing=none
$> cat ./dist/elements/runtime-es5.js ./dist/elements/polyfills-es5.js ./dist/elements/main-es5.js > ./dist/fbp-elements.js"

However, I would like to add --watch to that build task during development. But then I cannot run the concat task after each new build (because the build keeps running and is never ready)

This sounds like something for Angular CLI builders, which allows you to hook into the build process (thats what I've red). However, it is unclear to me how this is done. Are there any examples like this. It seems pretty new and without much documentation and examples yet out there. Any help would be appreciated!

Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
  • 1
    For those interested too, the easiest way to do this I think, if you are like me and don't know that much about the build process is to use [ngx-build-plus](https://github.com/manfredsteyer/ngx-build-plus). They have this nice argument called `--single-bundle` – Jeanluca Scaljeri Feb 22 '20 at 21:51
  • In your `package.json`, use the `postbuild` script hook it will call after every build is completed. Place your concat code there it will taken care. – Akilesh Kumar R Feb 25 '20 at 11:26
  • 3
    It doesn't seem to work. If I do `ng build --watch` the `postbuild` task is never executed, it is only run after a `ng build` – Jeanluca Scaljeri Feb 26 '20 at 07:04
  • Similar questions/answers that might help -> https://stackoverflow.com/a/42373547/9638991 (run two processes watching for changes at once) https://stackoverflow.com/a/54244963/9638991 (use ngx-build-plus) – kimbo Feb 26 '20 at 09:19

0 Answers0