Registry / web-framework / gatsby-alias-imports

gatsby-alias-imports

JSON →
library1.0.6jsnpmunverified

A Gatsby plugin that provides Webpack resolve aliasing for import statements, simplifying paths by mapping folders (default: all src subdirectories) to short aliases. Version 1.0.6 is the current stable release, with no active development observed since 2019. It works with Gatsby >2.0.0 and offers optional custom alias and root folder configuration. Unlike manual webpack configuration in gatsby-node.js, this plugin automates alias setup without additional boilerplate.

web-framework
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Plugins are added as strings in gatsby-config.js; importing as an ES module is incorrect.

module.exports = { plugins: [`gatsby-alias-imports`] }

Gatsby plugins expect object syntax with resolve and options keys; an array tuple is not supported.

module.exports = { plugins: [{ resolve: `gatsby-alias-imports`, options: { aliases: { Foo: `src/Foo` } } }] }

Aliases work with file extensions omitted; including them may cause resolution failures depending on webpack config.

import Header from 'components/Header'

Shows how to configure the plugin with custom aliases and use them in imports.

// gatsby-config.js module.exports = { plugins: [ `gatsby-alias-imports`, { resolve: `gatsby-alias-imports`, options: { aliases: { styles: `src/styles`, components: `src/components`, utils: `src/utils` } } } ] }; // Then in any file: import Header from 'components/Header'; import 'styles/main.css';
Debug
Known footguns
breakingPlugin uses resolve.symlinks: false by default, which may break node_modules resolution in linked packages or workspaces.
deprecatedNo updates since 2019; does not support Gatsby v5 (requires Gatsby >2.0.0 but untested with newer versions).
breakingAll values in options.aliases must be relative paths (e.g., 'src/styles'), not absolute paths starting with '/' or '../'.
gotchaIf rootFolder is not set, the plugin assumes '/src' as default root. Changing rootFolder may break existing aliases if they contain '/src'.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
Resources