Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: pwa. scopped options
  • Loading branch information
pooya parsa committed Jun 8, 2019
1 parent 1e1ae7b commit 010fe0e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
8 changes: 5 additions & 3 deletions docs/modules/icon.md
Expand Up @@ -10,11 +10,13 @@ sidebar: auto
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.


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

```js
icon: {
// Icon options
pwa: {
icon: {
/* icon options */
}
}
```

Expand Down
10 changes: 6 additions & 4 deletions docs/modules/manifest.md
Expand Up @@ -9,11 +9,13 @@ sidebar: auto

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

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

```js
manifest: {
name: 'My Awesome App',
lang: 'fa'
pwa: {
manifest: {
name: 'My Awesome App',
lang: 'fa'
}
}
```
6 changes: 3 additions & 3 deletions docs/modules/meta.md
Expand Up @@ -8,12 +8,12 @@ sidebar: auto
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/meta/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/meta)

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

```js
{
pwa: {
meta: {
// ...
/* meta options */
}
}
```
Expand Down
8 changes: 5 additions & 3 deletions docs/modules/workbox.md
Expand Up @@ -10,11 +10,13 @@ sidebar: auto
Workbox is a collection of JavaScript libraries for Progressive Web Apps.
([Learn more](https://developers.google.com/web/tools/workbox)). This module adds full offline support using workbox.

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).
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).

```js
workbox: {
// Workbox options
pwa: {
workbox: {
/* workbox options */
}
}
```

Expand Down
7 changes: 5 additions & 2 deletions lib/module.js
@@ -1,11 +1,14 @@
module.exports = async function nuxtPWA (options) {
const modules = ['icon', 'manifest', 'meta', 'workbox']

const pwaOptions = { ...this.options.pwa, ...options }

for (const name of modules) {
if (options[name] === false || this.options[name] === false) {
if (pwaOptions[name] === false || this.options[name] === false) {
continue
}
const moduleFn = require(`./${name}/module.js`)
const moduleOptions = { ...this.options[name], ...options[name] }
const moduleOptions = { ...this.options[name], ...pwaOptions[name] }
await moduleFn.call(this, moduleOptions)
}
}
Expand Down

0 comments on commit 010fe0e

Please sign in to comment.