Search code examples
angularangular.json

Upload file root of Angular and access


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


Solution

  • 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