Git Product home page Git Product logo

barrel-tool-js's Introduction

barrel-tool

Descripción de la imagen

image image

Barrel Tool is a utility designed to simplify the generation of "barrels" for your components. Barrels help efficiently organize and export components from multiple files, making their importation more straightforward.

Content

# Installation

Install barrel-tool with npm

npm i -D barrel-tool

or pnpm

pnpm add --save-dev barrel-tool

After that, generate a barrel.config.js

const barrelConfig = {
	dir: [
		// Add your folder names here:  './models', './utils'
	]
};

module.exports = barrelConfig;

# Usage

- Add your directory names

barrel.config.js

const barrelConfig = {
	dir: [
		// For example
		'./models', './libs', './components'
	]
};

module.exports = barrelConfig;

- Generate barrels

npx node node_modules/barrel-tool/src/barrel.generator.js 

- Watch barrels

npx node node_modules/barrel-tool/src/barrel.watch.js

- Add to package.json scripts (optional)

"scripts": {
"barrel-generator": "npx node node_modules/barrel-tool/src/barrel.generator.js",
"barrel-watch": "npx node node_modules/barrel-tool/src/barrel.watch.js"
}

# Settings

- Directory

Specify the directories that will be included in the barrel.

default:

dir: [
	// required
]

Example

dir: [
	'./models', './utils', './components'
]

Example components directory

- Save as

Specify the name of the barrel file. Recommended to use index.ts

default:

saveAs: 'index.ts'

- Use semicolon

Specify if you want to use semicolon at the end of each line.

default:

useSemicolon: false

Example

useSemicolon: true

Example useSemicolon

- Use extension

Specify if you want to use extension at the end of each line.

default:

useExtension: false

Example

useExtension: true

Example useExtension

- Separate by files

Specify if you want to separate the barrel by files.

default:

separateByFiles: false

Example

separateByFiles: true

Example separateByFiles

- Sub-folders

Specify if you want to include sub-folders.

default:

subFolders: true

Example subFolders True

Example

subFolders: false

Example subFolders False

Exclusions

Soon, we will add exclusions.

# Example

barrel.config.js

const barrelConfig = {
	dir: [
		'./components'
	],
	subFolders: false,
	separateByFiles: true,
	useSemicolon: true
}

module.exports = barrelConfig

barrel-tool-js's People

Contributors

ronaldtorrez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.