0

After I build my angular app, I have to perform one last manual step to get my program to run: The platform it runs on has a requirement that its javascript file is in the <head> of the html file that is running. Their .js is on a CDN. So basically, post-build, I have to open up index.html and add the following:

<script src="https://cdn.fragilecorp.com/lib/js/platform.js" type="text/javascript"></script>

Is there a way I can accomplish this automatically using angular configs or a different way?

1 Answer 1

0

Yes, in .angular-cli.json (.angular.json in older versions), I believe you can add what's inside of src to the scripts array.

Check this out:

How to include external JS file to angular5?

Sign up to request clarification or add additional context in comments.

2 Comments

That works for local files, but this one has to be referenced directly from the CDN. Can't reference a url in the scripts array.
OK my bad , check out the second answer here. To do it completely dynamic, you can read environments file to make sure you are in production mode to load it dynamically. httpss://stackoverflow.com/questions/34489916/how-to-load-external-scripts-dynamically-in-angular/42766146#42766146

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.