0.1.3 • Published 7 years ago

next-global-components v0.1.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Next.js - Global Components

This plugin implements Global Components on Next.js.

Installation

npm install --save next-global-components

or

yarn add next-global-components

Usage

Create a next.config.js in your project

// next.config.js
const options = {
  // VALUES
}
, { withGlobalComponents } = require('next-global-components')(options)

module.exports = withGlobalComponents()

Create a components.json in your root project

{
  "[Component Name]": "[Path]",
  "[Component Name]": ["[Path]", {
    "[Child Component Name]": "[Path]",
    "[Child Component Name]": "[Path]",
    "[Child Component Name]": "[Path]"
  }, true /*FOR GET ROOT COMPONENT*/]
}

The true will add root (index.js) from Parent Component

Eslint

// .eslintrc.js
const { eslint } = require('next-global-components')()

module.exports = {
  ...
  globals: eslint,
  rules: {
    'react/jsx-no-undef': ['error', { 'allowGlobals': true }]
  }
}

If you need get alias or provides

// next.config.js
const options = {
  // VALUES
}
, { alias, provides } = require('next-global-components')(options)

Options

OptionTypeDefaultInfos
ComponentsObject or Stringcomponents.jsonObject = { components } / String = Path File with Components
DirnameString./componentsPath where are yours Components

Next Config

Optionally you can add your custom Next.js configuration as parameter

// next.config.js
const { withGlobalComponents } = require('next-global-components')()
module.exports = withGlobalComponents({
  webpack(config, options) {
    return config
  }
})
0.1.3

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago