DEV Community

TK
TK

Posted on

5 2

How to import raw file with import.meta.glob() funciton of vite.js

When I use SvelteKit for blog system and I wanted to import markdown file as raw, so I use function of vite lie below


import.meta.glob('../data/*.md')

Enter fullscreen mode Exit fullscreen mode

But it didn't work.
Then the function occured error like below.

throw new Error(Parse failure: ${err.message}\\nContents of line ${line}: ${code.split('\\n')[line - 1]});
Enter fullscreen mode Exit fullscreen mode

Because I didn't configure settings of .md file.
I could solve the problem with vite-raw-plugin.

Top comments (1)

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

According to the docs - vitejs.dev/guide/features.html#glo...

import.meta.glob('../data/*.md', { as: 'raw' })
Enter fullscreen mode Exit fullscreen mode

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay