Skip to content

Local component name clashes for assets (workaround?) #162

Open
@dominicbarnes

Description

@dominicbarnes

My application has been structured with several root dirs such as "layouts", "routes" and "partials". Under each of those directories, each directory is a separate component, thereby keeping each package's assets self-contained. (and everything is wired together via local)

Unfortunately, once I have more than one component with the same name, (under different directories) I start having conflicts because there's only 1 "namespace" for copying assets. (eg. images)

I have tried a few different approaches, but none seem to work and there definitely should be a workaround here. (scripts/styles are handled fine, it's the assets that need to be handled better)

Attempt 1: I added a "suffix" (ie. "-partial", "-layout") in each component.json, hoping it would use that name for determining directory names. Unfortunately, that does not work, as it uses the "basename" no matter what.

Attempt 2: I tried using a more "abstracted" approach to pulling in those locals. For example, I used "locals": [ "partials/explore", ... ] (from the root) rather than using a partials/component.json. Unfortunately, that renames to partials-explore and cannot find the assets when it goes to copy/link them.

Attempt 3: I'm about to try renaming my directories to use the suffix mentioned in attempt 1. For example, partials/explore-partial, but that's tremendously clumsy and I feel like there should be a better way.

I think the assetsDest should be determined a little more intelligently, perhaps calculated based on it's path relative to the root. Perhaps, we can allow the component.json:name to override the usage of basename where it differs.

tl;dr

Using local components with the same directory name (even if from different directory trees like "routes" and "partials") results in conflicts when assets are copied. The process of copying assets should be a little more intelligent, or at least able to detect clashes.

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