`?raw` import works in vite (`nuxt dev`) but not in rollup (`nuxt generate`)
As described in the title
?raw
works in vite but not in rollup. Simple steps to reproduce:
npx nuxi@latest init raw
add app.css
edit app.vue
npm run dev
works.
npm run generate
results in following error.
I'm currently trying to convince rollup to understand the ?raw
import like vite does using the following, but I'm not sure how, or if that would even work..
7 Replies
does it also work when running npm run build (and then starting the node server)?
no.
npm run build
gives the same erroryeah, seems like a rollup issue then indeed π€
it's an offical vite feature https://vitejs.dev/guide/assets#importing-asset-as-string
not sure if we are supposed to use that if rollup doesn't support it, but as you can see, i've used it because vite supports it and now i run into the issue with rollup. not sure if it can be supported, but the solution that vite has using the raw declartion seems so tangible. any idea how to add the declarations to the rollup options in the nuxt config?
GitHub
Are
?raw
imports supported? Β· nuxt nuxt Β· Discussion #19694Vite allows importing an asset as a string using the ?raw suffix. When I try to do this with Nuxt, as far as I can tell it works as expected, however itβs not part of the default type definition pr...
feel free to raise an issue + link this discussion π
workaround for the meantime
pretty spartanic but gets the job done in the most straightforward and stable way