ionic-team / stencil

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
https://stenciljs.com
Other
12.61k stars 791 forks source link

assetsDirs ignored when used in more than one Component #2323

Open thomasschneiter opened 4 years ago

thomasschneiter commented 4 years ago

Stencil version:

 @stencil/core@1.11.3

I'm submitting a: [x ] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior: When adding assets to an asset folder in two different components components/comp1/assets/comp1.jpg components/comp2/assets/comp2.jpg and setting the assetsDirs in the components to use these them,

@Component({
    tag: 'xy-comp1',
    assetsDirs: ['assets'],
    ...
})

and

@Component({
    tag: 'xy-comp2',
    assetsDirs: ['assets'],
    ...
})

only one them is used.

When i build the components only one asset ends up in the dist/assets/ folder (probably the one that was first in the build process) and the following assets are ignored. A workaround is to use one global asset folder where all assets are located. The documentation suggests that it's possible to have one assets folder per component, which makes sense but doesn't seem to be the case.

Expected behavior: I would expect to have all assets moved to dist/assets/... when using one asset folder per component.

ElectricDanDan commented 4 years ago

Looks as though this only occurs when each component's assets folder has the same name. For example, the copy task doesn't complete when your structure is like this: comp1/assets/ comp2/assets/

But will succeed if you have directories like: comp1/comp1-assets/ comp2/comp2-assets/

adam-rocska commented 4 years ago

I'm more than happy to fix this issue on my time, if it's confirmed to be a bug & not an intended behavior.

Our project's also stalled by this issue & the fix shouldn't be that painful either with a decent added test coverage. My concept would be to recursively do "merge"-like operations until there's an exact collision of files. For those cases the current logic can remain, and a warning could be logged to the console (or maybe fail & error?) that there's a potentially unintended overwrite.

adam-rocska commented 4 years ago

Looks as though this only occurs when each component's assets folder has the same name. For example, the copy task doesn't complete when your structure is like this: comp1/assets/ comp2/assets/

But will succeed if you have directories like: comp1/comp1-assets/ comp2/comp2-assets/

@ElectricDanDan Thanks for the workaround idea! It's the cleanest we can get for now.