Gatsby plugin that configures Webpack to resolve modules from absolute paths, eliminating relative `../../` imports. Latest v2.0.9 supports Gatsby v2 through v5 via peer dependencies. Key differentiator: provides automatic `src` resolution without options, plus custom aliases and `resolveModules` for additional directories. Maintenance mode as of 2023; no active development but stable. Alternative: use Gatsby's native `resolve.alias` via Webpack config in `gatsby-node.js` for more control.
npm install gatsby-plugin-root-importVerified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin with custom resolveModules and aliases in gatsby-config.js, then import using the alias.
Update imports to include 'src/' prefix or configure root explicitly. For old behavior, set resolveModules to project root.
Use 'resolveModules' option instead to specify directories.
Ensure all alias paths use consistent case matching actual file system.
Add matching moduleNameMapper entries in Jest config as described in plugin README.
Place gatsby-plugin-root-import early in plugins array or consolidate configurations.
Either add 'src/' to import path, or configure resolveModules to include project root.
Verify the alias path in gatsby-config.js using absolute path (path.join).
Use compatible Gatsby version or remove plugin if using newer Gatsby.
Use the correct format: { resolve: 'gatsby-plugin-root-import', options: {...} }