laynezh / vite-plugin-lib-assets

A Vite Plugin extracts resource files referenced in library mode instead of embedded them as base64.
MIT License
86 stars 9 forks source link

Wrong path assets #89

Closed MBehtemam closed 1 week ago

MBehtemam commented 2 months ago

Hi , I have two fonts in my asset directory. Here is how I imported them in the theme.ts

import FoundryBook from "../assets/fonts/Font1.woff";
import FoundryBold from "../assets/fonts/Font2.woff";

And here is part of my config in vite.config :

libAssetsPlugin({
        limit: 1024 * 8,
        include: [/.*\.woff2?/g]
    })

But after building the library here is the output :

import M from "../assets/d572caf5b8dff4d1.woff"; import q from "./assets/21c7c48146cd70bf.woff";

Which cause this issue :

` ➜ press h to show help X [ERROR] Could not resolve "./assets/21c7c48146cd70bf.woff"

node_modules/@mylib/core-components/dist/theme/index.js:2:14:
  2 │ import m from "./assets/21c7c48146cd70bf.woff";      
    ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       `

Please let me know if you need more information .

MBehtemam commented 2 months ago

I commented the include part and surprisingly it is working.

coder-layne commented 2 months ago

@MBehtemam Thanks for your feedback, and can you provide a minimal reproducible version?