# gatsby-alias-imports

> Webpack alias resolver to gatsby

Latest version **1.0.6** (published 2020-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install gatsby-alias-imports
pnpm add gatsby-alias-imports
yarn add gatsby-alias-imports
bun add gatsby-alias-imports
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2020-10-26 |
| First published | 2019-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Luan Bitar |
| Maintainers | luanbitar |
| Keywords | gatsby, gatsby-plugin, alias, import, plugin, aliases, webpack, DefinePlugin, define, plugin |

## Links

- npm: https://www.npmjs.com/package/gatsby-alias-imports
- Repository: https://github.com/luanbitar/gatsby-alias-imports
- Homepage: https://github.com/luanbitar/gatsby-alias-imports#readme
- Issues: https://github.com/luanbitar/gatsby-alias-imports.git/issues
- npm.io page: https://npm.io/package/gatsby-alias-imports

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2020-10-26
- 1.0.4 — 2019-12-23
- 1.0.3 — 2019-12-09
- 1.0.2 — 2019-12-04
- 1.0.0 — 2019-12-04

## README

[![Version](https://img.shields.io/npm/v/gatsby-alias-imports.svg)](https://www.npmjs.com/package/gatsby-alias-imports)
[![Downloads Total](https://img.shields.io/npm/dt/gatsby-alias-imports.svg)](https://www.npmjs.com/package/gatsby-alias-imports)

# gatsby-alias-imports

Webpack feature for aliasing in your import statements, just import this plugin and all of your folders inside your `src` will be available with aliases.

```javascript
import "styles/layout.css"
import Header from "components/Header"
```

Instead of

```javascript
import "../../styles/layout.css"
import Header from "../components/Header/index.js"
```

## Install

`$ npm i gatsby-alias-imports`

or

`$ yarn add gatsby-alias-imports`

## How to use

Add the plugin to your `gatsby-config.js`.

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

## Options

### aliases

Alias should be an object where the keys are alias and values are string to path on project

Example:
```javascript
module.exports = {
  plugins: [
    {
      resolve: `gatsby-alias-imports`,
      options: {
        aliases: {
          styles: `src/styles`,
          config: `config/`,
          "@utils": "src/utils/"
        }
      }
    }
  ]
}
```

### rootFolder

The **rootFolder** it's in case you change your `src` folder name
```javascript
module.exports = {
  plugins: [
    {
      resolve: `gatsby-alias-imports`,
      options: {
        rootFolder: `app`
      }
    }
  ]
}
```

## Further reading

Check out the [resolve section][1] of the Webpack config documentation for more information.

[1]: https://webpack.js.org/configuration/resolve/#resolve-alias

---
_Source: https://npm.io/package/gatsby-alias-imports · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
