Skip to content

Images not shown as expected after build Fresh project #3482

@eduardorangell

Description

@eduardorangell

Hi there,

I'm using Fresh 2.1.1 and i have the assets and static folders. When working on dev mode (deno task dev) the website work as expected rendering both images on HTML <img> tag and on bg-[url(image/about/image-1.webp) CSS attribute, but after building the project using deno task build, the code expect that the file bg-[url(image/about/image-1.webp) is placed on assets folder, not on static.

I have ran the following steps:

  • deno run -Ar jsr:@fresh/init (set yes to tailwindcss and vscode).
  • created image folder into static folder and pasted both images.
  • modified index.ts into this:
import { Head } from "fresh/runtime";
import { define } from "../utils.ts";

export default define.page(function Home(ctx) {
  console.log("Shared value " + ctx.state.shared);

  return (
    <div class="px-4 py-8 mx-auto fresh-gradient min-h-screen">
      <Head>
        <title>Fresh counter</title>
      </Head>
      <div class="max-w-screen-md mx-auto flex flex-col items-center justify-center">
        <img
          class="my-6"
          src="image/image-2.png"
        />
        <div class="bg-[url('image/image-1.png')] bg-[length:200dvw] bg-right bg-no-repeat md:w-1/2 md:bg-[length:65dvw]">
          <div class="px-4 py-20 md:py-72">
            <h1 class="text-4xl">
              TEST
            </h1>
          </div>
        </div>
      </div>
    </div>
  );
});
  • deno task build and noticed the following message on terminal: image/image-1.png referenced in image/image-1.png didn't resolve at build time, it will remain unchanged to be resolved at runtime.
  • deno task start and noticed the wrong refference on network tab.

Thank you for your attention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions