Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is "public" folder in Angular project?

I have generated a new Angular 18 project. I have noticed that it created a "public" folder instead of "src/assets", where does it come from?

It looks like this was used in previous versions and now it came back?
https://github.com/angular/angular-cli/issues/1942

I would like to generate a new project that uses "src/assets" folder, is there a setting or a parameter I can use so that it’s created automatically when generating a project or do I have to make the change manually after I generate the project?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Reading through the angular documentation it doesn’t look like there’s a parameter that you can pass to specify the assets folder path when using ng new

https://next.angular.io/cli/new

Luckily it shouldn’t take much to change the assets folder once the project is created. All you have to do is:

  1. move the public folder under src/

  2. rename it into assets
    1a. Alternatively delete the public folder and create the src/assets folder (since the folder only contains the favicon.ico file it shouldn’t be a problem)

  3. then change the assets value inside angular.json under architect => build and architect => test (that is, there should be 2 places where the public folder is mentioned in the angular.json file)

    "assets": [
    {
    glob": "**/*",
    input": "src/assets"
    }
    ]

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading