Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage outside of Vue Components #2

Open
digitalkaoz opened this issue Mar 30, 2024 · 2 comments
Open

Usage outside of Vue Components #2

digitalkaoz opened this issue Mar 30, 2024 · 2 comments

Comments

@digitalkaoz
Copy link

digitalkaoz commented Mar 30, 2024

im having trouble using this in None-Vue-Code (still nuxt3 but on the serverside)

import Logo from "~/assets/logo.svg?raw"

export default defineEventHandler(async (event) => {
  //do something with the logo here
}

the error im getting:

 ERROR  Error: Could not load /.../assets/logo.svg?raw (imported by model/pdf.ts): ENOENT: no such file or directory,  open '/.../assets/logo.svg?raw'

so i guess the loader is not active everywhere? i guess it should?

doing the same in a vue component works flawless!

using a different loader technique (none in this case):

import Logo from "~/assets/logo.svg"
WARN  (inject plugin) rollup-plugin-inject: failed to parse /.../assets/logo.svg. Consider restricting the plugin to particular files via options.include                                                                                                                                                           10:26:40 PM


 ERROR  RollupError: Expression expected (Note that you need plugins to import files that are not JavaScript)                                                                                                                                                                                                                                           nitro 10:26:40 PM


1: <svg xmlns="http://www.w3.org/2000/svg" width="280" height="186" fill="none"><path fill="#0C4A6E" d="M20.25 175.65c.9...
   ^
@digitalkaoz
Copy link
Author

i have a feeling its linked to jpkleemans/vite-svg-loader#117 ?

@Mini-ghost
Copy link
Owner

I'm thinking this issue might be tied to the nitro server, which seems to struggle with importing file types like .png and .svg. If we're looking to work with raw files on the server, it might be a good idea to look into using a file system package, such as fs or fs-extra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants