# react-static-plugin-include-external-path

> A React-Static plugin that adds external path support for webpack imports

Latest version **1.0.2** (published 2019-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-static-plugin-include-external-path
pnpm add react-static-plugin-include-external-path
yarn add react-static-plugin-include-external-path
bun add react-static-plugin-include-external-path
```

## 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.2 |
| Published | 2019-10-16 |
| First published | 2019-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Henry Young |
| Maintainers | henry.r.t.young |
| Keywords | react, react-static, react-static-plugin, plugin, monorepo, external |

## Links

- npm: https://www.npmjs.com/package/react-static-plugin-include-external-path
- Repository: https://github.com/henry-young/react-static-plugin-include-external-path
- Homepage: https://github.com/henry-young/react-static-plugin-include-external-path#readme
- Issues: https://github.com/henry-young/react-static-plugin-include-external-path/issues
- npm.io page: https://npm.io/package/react-static-plugin-include-external-path

## Dependencies (2)

- [glob](https://npm.io/package/glob.md) ^7.1.4
- [chokidar](https://npm.io/package/chokidar.md) ^3.0.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-10-16
- 1.0.1 — 2019-10-16
- 1.0.0 — 2019-10-14

## README

# react-static-plugin-include-external-path

A [React-Static](https://react-static.js.org) plugin that adds external path support for webpack imports.

This exposes a simple way to share components and functionality between sites in a monorepo without requiring extra compilation, private npm packages or symbolic links.

## Installation

In an existing react-static site run:

```bash
$ yarn add react-static-plugin-include-external-path
```

Then add the plugin to your `static.config.js` with a valid `includePath` directory and alias in the options:

```javascript
...
import path from 'path'
...
export default {
  plugins: [
    [
      'react-static-plugin-include-external-path',
      {
        includePath: path.resolve('../shared'),
        alias: "@shared"
      },
    ],
  ],
}
```

## Usage
You will now be able to import files from the `../shared` folder in your project using the `@shared` alias.

Example:
```jsx
// '../shared/SharedComponent.jsx'
import React from 'react';
export default () => <div>Shared Component</div>
```
Then import using relative path or alias
```jsx
// Any component in your "./src" folder
...
import SharedComponent from '@shared/SharedComponent';
...
export default () => <SharedComponent/>
```

## Typescript usage
When using this plugin with `react-static-plugin-typescript`, you must add the includePath and alias to `compilerOptions.paths` in your sites `tsconfig.json`

Example:
```json
{
  ...
  "compilerOptions":  {
    ...
    "paths": {
        ... 
        "@shared/*": ["../shared/*"]
      }
  }
}
```

---
_Source: https://npm.io/package/react-static-plugin-include-external-path · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
