0

I am looking to upload a .js file example.js to Angular root and want to access it directly via localhost:3000/example.js

I have tried adding the file directly to root and also made changes to angular.json but nothing seems to work.

Is there a way to achieve this without copying the file to assets directory.

Any config changes in Angular.json

Raphaël Balet
9,1398 gold badges65 silver badges118 bronze badges
asked Feb 6, 2024 at 11:22

1 Answer 1

1

You have to add it inside your assets array, inside your angular.json file.

The file need at least to be inside your src folder though.

so this would be

src
 -- assets
 -- example.js

Then

"assets": [
 "src/assets",
 "src/example.js"
 ...
]

Cheers

answered Feb 6, 2024 at 12:23
Sign up to request clarification or add additional context in comments.

1 Comment

This works on my end

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.