Currently, I'm trying to import MD files in Astro using the following code:
import * as a from '../content/a.md';
This code works perfectly fine when I'm running "npm run dev", but it throws an error during build as follows:
Assigning to rvalue (Note that you need plugins to import files that are not JavaScript)
I've found out that during "npm run dev", it references "declare module '*.md'" in client-base.d.ts.
However, I don't think it's referencing during the build process.
How can I make sure that I can import MD files during the build process in Astro?
I created an md.d.ts file to mimic the declaration in client-base.d.ts:
declare module '*.md' {
const content: string;
export default content;
}
I then added the md.d.ts file to my tsconfig.json to include it in the build process:
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"strictNullChecks": true
},
"include": [
"md.d.ts"
]
}