Skip to content

Documenting __VITE_ASSET__ or exposing a function to build asset url. #13459

Description

@cijiugechu

Documentation is

  • Missing
  • Outdated
  • Confusing
  • Not sure?

Explain in Detail

Currently in plugin development, if you want to emit a file and then reference it, you need to use the __VITE_ASSET__${fileHandle}__ pattern to get the url , there are many examples like this, such as imagetools.

The problem is : this pattern is undocumented, and subsequent plugin developers need to view the source code to continue development.

Your Suggestion for Changes

  1. Document this section in the same way as Rollup's File URLs.
  2. Expose a new function like buildAssetUrl : The function receives fileHandle as an argument and returns the corresponding asset url.

Reproduction

No response

Steps to reproduce

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions