Closed Boston343 closed 1 year ago
Try using an absolute path with $PROJECT_ROOT
acting as /
.
Given a component src/components/Note.astro
:
export default defineConfig({
// ...
integrations: [
// ...
AutoImport({
imports: ["/src/components/Note.astro"],
)},
mdx(),
],
// ...
});
Mind you this has been tested for exactly one usage of one component on one page. I just came across the same problem, saw this issue, and tried an idea. So far it works.
Ah, yes — sorry I somehow missed the original bug report — as @brianwisti says, the intended usage is with a path building up from /
as the root of your project.
I think that should work and therefore this is not really a bug, so I'll close this. Feel free to comment or reopen if you run into difficulty though!
The package seems to be non-functional at the moment. The error I am getting makes me think the package is going to the base project folder, then taking into account any
../
in the file path, then removing all the slashes. So it's trying to access a non-existent folder structure.Basic repo with issue shown is here https://github.com/Boston343/astro-auto-import-test
For this repo, the mdx file in question is
using-mdx.mdx
which is the example file from astros blog starter. I removed the include that was in the file, and instead am using the AutoImport to try and add the component import into the mdx file. This throws errors.astro.config.mjs
The error looks like: