Get raw string value by import with vite

Viewed 1903

I want to get raw string of css in npm module through vite. According to vite manual,
https://vitejs.dev/guide/assets.html#importing-asset-as-string
It says we can get raw string by putting "?raw" at the end of identifier.

So I try this:

import style from "swiper/css/bundle?raw";

But this shows error like:

[vite] Internal server error: Missing "./css/bundle?raw" export in "swiper" package

If I use this:

import style from "swiper/css/bundle";

There are no error, but css is not just load as string but handled as bundle css.
This is not good, because I want to use this css in my lit-based web components.
Are there any way to get css as raw string through vite?

1 Answers
Related