Skip to content

Commit

Permalink
fix(dev): make ~ imports work for markdown files
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <[email protected]>
  • Loading branch information
mcansh committed Oct 12, 2021
1 parent 7db4127 commit a429fc9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions fixtures/gists-app/app/routes/blog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { HeadersFunction, LinksFunction, LoaderFunction } from "remix";
import { Link, useRouteData, usePendingLocation, json } from "remix";

import stylesHref from "../../styles/gists.css";
import * as helloPost from "./hello-world.mdx";
import * as secondPost from "./second.md";
import * as thirdPost from "./third.md";

import stylesHref from "~/styles/gists.css";
import * as secondPost from "~/routes/blog/second.md";

interface Post {
title: string;
description: string;
Expand Down
4 changes: 3 additions & 1 deletion packages/remix-dev/compiler/plugins/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export function mdxPlugin(config: RemixConfig): esbuild.Plugin {

build.onResolve({ filter: /\.mdx?$/ }, args => {
return {
path: path.resolve(args.resolveDir, args.path),
path: args.path.startsWith("~/")
? path.resolve(config.appDirectory, args.path.replace(/^~\//, ""))
: path.resolve(args.resolveDir, args.path),
namespace: "mdx"
};
});
Expand Down

0 comments on commit a429fc9

Please sign in to comment.