Currently, I am facing an issue with importing MD files in Astro and I am using the following code snippet:
import * as a from '../content/a.md';
While this code works perfectly fine when running "npm run dev", it throws an error during the build process:
Assigning to rvalue (Note that you need plugins to import files that are not JavaScript)
Upon investigation, I discovered that during "npm run dev", it references "declare module '*.md'" in client-base.d.ts file. However, it seems that this reference is not used during the build process.
So, my question is, how can I ensure that I am able to import MD files successfully during the build process in Astro?
To try and solve this issue, I created an md.d.ts file to replicate the declaration in client-base.d.ts:
declare module '*.md' {
const content: string;
export default content;
}
I then included the md.d.ts file in my tsconfig.json to incorporate it into the build process:
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"strictNullChecks": true
},
"include": [
"md.d.ts"
]
}