Skip to content

Default assetsInclude are case sensitive #19851

@Mister-Hope

Description

@Mister-Hope

Describe the bug

Image

When you export images and videos from iPhone, all file extensions are all UPPER_CASE by default, e.g.: .JPG .PNG, .MOV.

While Vite default assetsInclude option are case-sensitive, and only allow lowercase file ext.

This means before changing the ext or modifying assetsInclude options, these media won't work in Vite.

I also checked the definition of file ext and some media ones, and I am not finding any specification
telling these files must use lowercase extensions (i.e Apple is wrong).

export const DEFAULT_ASSETS_RE = new RegExp(
`\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`,
)

Thus, this should be a bug, and I think a i flag shall be added here.

Reproduction

I think this is not needed as a only a i flag needs to be aded on a RegExp to fix this.

Steps to reproduce

Import any uppercase asset, you will get the following error msg:

[plugin:vite:import-analysis] Failed to parse source for import analysis because the content contains invalid JS syntax. You may need to install appropriate plugins to handle the .PNG file format, or if it's an asset, add "**/*.PNG" to assetsInclude in your configuration.
D:/cygwin64/home/ReWi/EmbedReWi/src/reference/images/STM32.PNG

Ref: vuepress-theme-hope/giscus-discussions#1042 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions