Skip to content

Usage outside of Vue Components #2

@digitalkaoz

Description

@digitalkaoz

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...
   ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions