Skip to content

Commit 320086e

Browse files
committed
chore: update usage
1 parent cbebed7 commit 320086e

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

README.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
[![npm downloads][npm-d-src]][npm-d-href]
55
[![ci][ci-src]][ci-href]
66

7-
Add config extending support to Nuxt 2 projects!
7+
This utility allows extending a nuxt project based on another one by smartly merging `nuxt.config` files.
88

9-
## Features
9+
It can be useful if:
10+
- You want to share a base config across mono-repo projects
11+
- You want to create a multi-variant (like `mobile`/`desktop`) app
12+
- You want to create a reusable nuxt theme (like one for docs)
1013

11-
- Support nested `extends`
12-
- Smartly merge config and hooks
13-
- Allow theme development to be like a normal nuxt project
14+
**Note:** Proper Multi-App ([rfc](https://github.com/nuxt/rfcs/issues/30)) is comming with nuxt3 which also
15+
allows extending auto scanned directories like `pages/` and `store/` and merging them.
1416

15-
## Usage
17+
## Mobile/Desktop Demo
18+
19+
See [this example](./example)
1620

17-
### Common Setup
21+
## Usage
1822

1923
Install `nuxt-extend` as a dependency:
2024

@@ -29,10 +33,10 @@ npm i nuxt-extend
2933
Update `nuxt.config` file:
3034

3135
```js
32-
import { resolveConfig } from 'nuxt-extend'
36+
import { nuxtConfig } from 'nuxt-extend'
3337

34-
export default resolveConfig({
35-
// Your actual Nuxt configuration
38+
export default nuxtConfig({
39+
/* your actual nuxt configuration */
3640
})
3741
```
3842

@@ -41,29 +45,29 @@ export default resolveConfig({
4145
Use `extends` key in `nuxt.config`:
4246

4347
```js
44-
import { resolveConfig } from 'nuxt-extend'
48+
import { nuxtConfig } from 'nuxt-extend'
4549

46-
export default resolveConfig({
47-
extends: '@nuxt/docs-theme',
50+
export default nuxtConfig({
51+
extends: '<path to base or npm package>',
4852
})
4953
```
5054

51-
### Child
55+
### Base
5256

53-
1. Update `nuxt.config` and ensure required `rootDir` and `name` properties are provided
57+
- Update `nuxt.config` and ensure required `rootDir` and `name` properties are provided
5458

5559
```js
56-
import { resolveConfig } from 'nuxt-extend'
60+
import { nuxtConfig } from 'nuxt-extend'
5761

58-
export default resolveConfig({
62+
export default nuxtConfig({
5963
rootDir: __dirname,
6064
name: 'myTheme',
6165
}
6266
```
6367
64-
**Note:** If you are extending another theme, `rootDir` should be ONLY provided if you want to also extend project.
68+
**Note:** If you are extending recusively, `rootDir` should be ONLY provided one one level that implements actual `pages/` and `store/`.
6569
66-
2. Instead of using `~/` or `@/` aliases, use `~myTheme` or `@myTheme`
70+
- Instead of using `~/` or `@/` aliases, use `~myTheme` or `@myTheme`
6771
6872
## License
6973

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"build": "siroc build",
1414
"dev": "nuxt test/fixture/app -c nuxt.config.cjs.js",
1515
"lint": "eslint --ext .ts src",
16+
"prepare": "yarn link && yarn link nuxt-extend",
1617
"prepublish": "yarn build",
1718
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
1819
"test": "yarn lint && yarn jest"

0 commit comments

Comments
 (0)