Skip to content

Commit

Permalink
Allow webpack loaders for relative imports (gatsbyjs#374)
Browse files Browse the repository at this point in the history
* Allow webpack loaders for relative imports

* Clean loader path logic
  • Loading branch information
redallen authored and ChristopherBiscardi committed Jun 27, 2019
1 parent 46c7541 commit d7e4102
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/gatsby-plugin-mdx/gatsby/on-create-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ class BabelPluginTransformRelativeImports {
return {
visitor: {
StringLiteral({ node }) {
if (node.value.startsWith(".")) {
const valueAbsPath = path.resolve(parentFilepath, node.value);
const replacementPath = path.relative(
let split = node.value.split('!');
const nodePath = split.pop();
const loaders = `${split.join('!')}${split.length > 0 ? '!' : ''}`;
if (nodePath.startsWith(".")) {
const valueAbsPath = path.resolve(parentFilepath, nodePath);
const replacementPath = loaders + path.relative(
path.join(cache.directory, MDX_SCOPES_LOCATION),
valueAbsPath
);
Expand Down

0 comments on commit d7e4102

Please sign in to comment.