Skip to content

Commit 010fe0e

Browse files
author
pooya parsa
committed
feat: pwa. scopped options
1 parent 1e1ae7b commit 010fe0e

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

docs/modules/icon.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ sidebar: auto
1010
This module automatically generates app icons and favicon with different sizes using [jimp](https://github.com/oliver-moran/jimp) and fills `manifest.icons[]` with proper paths to generated assets that is used by manifest module. Source icon is being resized using *cover* method.
1111

1212

13-
You can pass options to `icon` section in `nuxt.config.js` to override defaults.
13+
You can pass options to `pwa.icon` in `nuxt.config.js` to override defaults.
1414

1515
```js
16-
icon: {
17-
// Icon options
16+
pwa: {
17+
icon: {
18+
/* icon options */
19+
}
1820
}
1921
```
2022

docs/modules/manifest.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ sidebar: auto
99

1010
Manifest adds [Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) with no pain.
1111

12-
You can pass options to `manifest` section in `nuxt.config.js` to override defaults.
12+
You can pass options to `pwa.manifest` in `nuxt.config.js` to override defaults.
1313

1414
```js
15-
manifest: {
16-
name: 'My Awesome App',
17-
lang: 'fa'
15+
pwa: {
16+
manifest: {
17+
name: 'My Awesome App',
18+
lang: 'fa'
19+
}
1820
}
1921
```

docs/modules/meta.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ sidebar: auto
88
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/meta/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/meta)
99

1010
Meta easily adds common meta tags into your project with zero-config needed.
11-
You can optionally override meta using either `manifest` or `meta` section of `nuxt.config.js`:
11+
You can optionally override meta using `pwa.meta` in `nuxt.config.js`:
1212

1313
```js
14-
{
14+
pwa: {
1515
meta: {
16-
// ...
16+
/* meta options */
1717
}
1818
}
1919
```

docs/modules/workbox.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ sidebar: auto
1010
Workbox is a collection of JavaScript libraries for Progressive Web Apps.
1111
([Learn more](https://developers.google.com/web/tools/workbox)). This module adds full offline support using workbox.
1212

13-
You can pass options to `workbox` section in `nuxt.config.js` to override the [defaults](https://github.com/nuxt-community/pwa-module/blob/master/packages/workbox/lib/defaults.js).
13+
You can pass options to `pwa.workbox` in `nuxt.config.js` to override the [defaults](https://github.com/nuxt-community/pwa-module/blob/dev/lib/workbox/defaults.js).
1414

1515
```js
16-
workbox: {
17-
// Workbox options
16+
pwa: {
17+
workbox: {
18+
/* workbox options */
19+
}
1820
}
1921
```
2022

lib/module.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
module.exports = async function nuxtPWA (options) {
22
const modules = ['icon', 'manifest', 'meta', 'workbox']
3+
4+
const pwaOptions = { ...this.options.pwa, ...options }
5+
36
for (const name of modules) {
4-
if (options[name] === false || this.options[name] === false) {
7+
if (pwaOptions[name] === false || this.options[name] === false) {
58
continue
69
}
710
const moduleFn = require(`./${name}/module.js`)
8-
const moduleOptions = { ...this.options[name], ...options[name] }
11+
const moduleOptions = { ...this.options[name], ...pwaOptions[name] }
912
await moduleFn.call(this, moduleOptions)
1013
}
1114
}

0 commit comments

Comments
 (0)