Skip to content

Using pluginEntry and pluginImage together can cause the build to crash or emit an unnecessary duplicate asset depending on plugin order #141

Description

@kyouhei-horizumi

When pluginEntry() and pluginImage() are enabled at the same time, one of the following issues occurs depending on the order of the plugins in minista.config.js.

Steps to reproduce

// minista.config.js
import { defineConfig, pluginSsg, pluginEntry, pluginImage } from "minista"

export default defineConfig({
  plugins: [pluginSsg(), pluginEntry(), pluginImage()],
})
// src/pages/index.jsx
import { Image } from "minista/assets"

export default function () {
  return <Image src="/src/assets/images/photo.png" alt="photo" />
}

Run:

minista build

Actual behavior

Pattern 1: pluginEntrypluginImage

The build fails with the following error:

[plugin vite-plugin:minista-image]
TypeError: Cannot destructure property 'fileName' of 'recipe' as it is undefined.
    at resolveOptimizeOption (.../plugins/image/utils/option.js:16:11)
    at selfGetElData (.../plugins/image/index.js:253:22)
    at PluginContextImpl.generateBundle (.../plugins/image/index.js:481:55)

Pattern 2: pluginImagepluginEntry

The build succeeds, but an extra unreferenced, unoptimized copy of the original image is emitted to dist/assets/ (for example, photo-XXXXXXXX.png).

The <img> element in dist/index.html correctly references the optimized srcset, so the extra file does not affect the rendered result, but an unnecessary asset is included in the build output.

Expected behavior

Using pluginEntry and pluginImage together should build successfully regardless of plugin order, without emitting unnecessary duplicate assets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions