From 5138cd9d13f0aa8a429be68351c86c54e788e20e Mon Sep 17 00:00:00 2001 From: Dave Stewart Date: Fri, 11 Sep 2020 11:32:01 +0100 Subject: [PATCH] Update docs --- README.md | 11 +++++++++-- docs/cli/paths.md | 25 ++++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a5511bc..a5a5e43 100644 --- a/README.md +++ b/README.md @@ -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: ``` @@ -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 :) diff --git a/docs/cli/paths.md b/docs/cli/paths.md index e04f586..0b3b9d7 100644 --- a/docs/cli/paths.md +++ b/docs/cli/paths.md @@ -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 \ No newline at end of file +- 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