Forgive me as I am new to Angular.
I have recently added a script file into the src/assets/scripts folder and have placed its path under the scripts section in angular.json.
Question is: Do I need to re-run ng serve
so that it will be loaded the next time the application runs?
Appreciate the responses.
CodePudding user response:
By default, If you mention any script in the angular.json
it will be part of the bundle(meaning its automatically included). If you don't want that to happened, there is a different way to inject the script:
"scripts": [
{
"input": "src/external-module/main.js",
"inject": false,
"bundleName": "external-module"
}
]
This way the script will be part of the dist, but will not be added to the index.html
. You'll have to manually load it or add it to the index.html
Ref: https://angular.io/guide/workspace-config#styles-and-scripts-configuration