close
Skip to content

WP Build: support image imports #75130

@simison

Description

@simison

What problem does this address?

WP Build should support importing images and converting them to asset paths:

import image from './image.png';

const Example () => (
  <img src={ image } />
);

There might not be a need at the moment in Gutenberg for this, but for plugins using the build tool, this would be a fairly basic feature to support. Otherwise, it becomes harder to point to the right image path on the server from React components.

What is your proposed solution?

Adding Asset modules into the WP Build package.

Features:

  • It would be great if this supports PNG, GIF, JPG, and svg files.
  • Images would get cache-busted between builds using hashes.
  • WP Build would take care of configuring a publicly accessible path for images in build folder.

Here's an example from Jetpack plugin's build tool: file rule and docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions