farm-fe / farm

Extremely fast Vite-compatible web build tool written in Rust
https://farmfe.org
MIT License
4.09k stars 140 forks source link

[Help Wanted]: looking for a better way to export assets when building libraries #1412

Open niuiic opened 2 weeks ago

niuiic commented 2 weeks ago

Steps to reproduce

For an example, you can check this project.

packages/webgl/src/components/snow/index.ts

import snowflakeUrl from '@/assets/images/snowflake.png'

snowflakeUrl may be transformed to '/snowflake.hash.png', which is definitely wrong when use this library in another project.

Thus, I have to import assets inline, but it slows down the prebuild for the project using this library.

@laynezh/vite-plugin-lib-assets is an awesome solution for vite, but does not seem to work with farm.

Reproduce link

No response

What is actually happening?

x

System Info

System:
    OS: Linux 6.9 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 9.98 GB / 15.58 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.2.0 - /run/user/1000/fnm_multishells/4278_1718689209819/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.7.0 - /run/user/1000/fnm_multishells/4278_1718689209819/bin/npm
    pnpm: 9.4.0 - /run/user/1000/fnm_multishells/4278_1718689209819/bin/pnpm
  npmPackages:
    @farmfe/core: ^1.1.15 => 1.1.15
wre232114 commented 2 weeks ago

I'll take a look