Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "public" folder in Angular project? [duplicate]

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?

like image 514
smartmouse Avatar asked Oct 30 '25 10:10

smartmouse


1 Answers

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"
        }
    ]
    
like image 101
valepu Avatar answered Nov 01 '25 02:11

valepu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!