Skip to content

Assets with the Same Name, but Different Path, are Copied Over Each Other #19850

Closed
@maks-humeniuk

Description

@maks-humeniuk

🐞 Bug report

Command (mark with an x)

  • serve
  • build

Is this a regression?

I don't know, since never needed this before.

Description

Assets with the same name, but different path, are copied over each other on ng serve or ng build --prod with "outputHashing": "none".

🔬 Minimal Reproduction

.dark {
  background-image: url('../../../assets/images/dark/logo.png');
}

.light {
  background-image: url('../../../assets/images/light/logo.png');
}

Both images will be copied to the output directory with the same name, so you only get the dark or light logo, that will be used in both cases.

This won't be an issue on ng build --prod with "outputHashing": "all" or "outputHashing": "media".

This also won't be an issue on ng serve --prod, as per this comment, but will definitely slow down local debugging.

This could be fixed by using assets relative path (/assets instead of ../../../assets), but then it would be an issue on ng build --prod, since I don't include assets/images in assets in angular.json. The reason is that I don't want them to be duplicated (in assets and root folder), and this is by design, as per this comment.

🔥 Exception or Error

WARNING in Conflict: Multiple assets emit different content to the same filename logo.png

🌍 Your Environment


    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 11.0.7
Node: 14.15.0
OS: win32 x64

Angular: 11.0.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.7
@angular-devkit/build-angular   0.1100.7
@angular-devkit/core            11.0.7
@angular-devkit/schematics      11.0.7
@angular/cli                    11.0.7
@schematics/angular             11.0.7
@schematics/update              0.1100.7
rxjs                            6.6.3
typescript                      4.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions