Upload file root of Angular and access

30 Views Asked by At

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

1

There are 1 best solutions below

1
On BEST ANSWER

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