How to use the use.defaultOptions function in use

To help you get started, we’ve selected a few use examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gridsome / gridsome / packages / gridsome-core / lib / bootstrap / initPlugins.js View on Github external
module.exports = async service => {
  service.plugins = Array.isArray(service.config.plugins)
    ? service.config.plugins.map(normalize).filter(plugin => !!plugin.use)
    : []

  for (let i = 0, l = service.plugins.length; i < l; i++) {
    const plugin = service.plugins[i]
    const use = plugin.use.replace(internalRE, '../')

    plugin.uid = uid(use, i)
    plugin.api = new PluginAPI(service, plugin)

    try {
      const func = require(use)
      const options = defaultsDeep(plugin.options, func.defaultOptions)
      await func(plugin.api, options)
    } catch (err) {}
  }
}

use

Easily add plugin support to your node.js application.

MIT
Latest version published 6 years ago

Package Health Score

68 / 100
Full package analysis