Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
davestewart committed Sep 11, 2020
1 parent 3439833 commit 5138cd9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ Alias HQ is [configured](./docs/cli/paths.md) using your project's `ts/jsconfig.
The [API](./docs/api/api.md) makes sure your IDE, framework and toolchain are always in sync:

```js
config.resolve.aliases = hq.get('webpack') // choose any plugin; jest, rollup, etc
```
// webpack.config.js
config.resolve.alias = hq.get('webpack')

// jest.config.js
config.moduleNameMapper = hq.get('jest')

// etc...
```
The [CLI](./docs/cli/cli.md) makes sure your code is always up-to-date:

```
Expand Down Expand Up @@ -104,4 +109,6 @@ For a short video:

- [Click here](https://twitter.com/i/status/1298592287266611205)

Wanna support the project?

- Tweet or [retweet](https://twitter.com/dave_stewart/status/1297906829868109825) about it :)
25 changes: 16 additions & 9 deletions docs/cli/paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,22 @@ Once you complete these steps, Alias HQ will show you a preview of the new confi

## Notes

The configuration requires:
These notes provide some practical and conceptual advice about Microsoft's [configuration](https://code.visualstudio.com/docs/languages/jsconfig#_using-webpack-aliases) format.

- The `baseUrl` to provide a relative entry point such as `"."` or `"src"`
- The `paths` to be specified using Microsoft's [somewhat verbose](https://code.visualstudio.com/docs/languages/jsconfig#_using-webpack-aliases) wildcard and array format
Folders:

Note that:
- The `baseUrl` is a *relative* folder path to the project's *absolute* `rootUrl` such as `"."` or `"src"`
- Any `paths` **must** resolve from the `baseUrl`, so if you need to go up a level from `src`, something like this is fine: `../packages`
- The format supports [multiple paths](https://www.typescriptlang.org/tsconfig#paths), though
- the CLI will only write a single path
- Jest is the only library to utilise this

Content:

- You may add non-TypeScript paths (such as assets, for use in Webpack) here; TypeScript will ignore them but Alias HQ will use them
- Aliases also support **files**, so you can enter something like this: `core/config/settings.js` and it will be aliased to `@settings`

Naming:

- All `paths` should resolve from the `baseUrl`, so something like this is fine: `../node_modules/`
- To resolve folder content, wildcards are required in both `alias` and `path` components
- The format supports [multiple paths](https://www.typescriptlang.org/tsconfig#paths), though currently Jest is the only conversion format to utilise this
- You may add non-TypeScript paths (such as assets) here; TypeScript will ignore them but Alias HQ will use them
- You don't *have* to use a `@` character, but the convention is to use one
- Alias `name`s can be any valid folder name; you don't *have* to use a `@` character, but the convention is to use one to make them recognisable
- To resolve **folder** content, both the alias `name` and `path` components require trailing wildcards

0 comments on commit 5138cd9

Please sign in to comment.