1.0.1 • Published 5 years ago
component-indexer v1.0.1
component-indexer
Node module. Creates an _index file in a specified directory that references all of the files in that directory. This is useful for bulk importing SCSS modules or Pug mixins. Contains presets for SCSS and Pug, or options can be specified manually.
Usage
Given this file structure—
.
└── src
└── pug
└── mixins
├── _blockquote.pug
├── _section.pug
└── _card.pugconst componentIndexer = require('component-indexer')
componentIndexer('src/pug/mixins', 'pug')—the above will create ./src/pug/mixins/_index.pug with this content:
include _blockquote
include _card
include _sectionSyntax
componentIndexer(path, filetype [,{prefix, suffix, extension}])Options
path(String) Relative path to the directory to be indexedfiletype: (String) Extension of the files to be indexedprefix: (String, optional) Prepended before each file name in the index filesuffix: (String, optional) Appended after each file name in the index fileextension: (Boolean, optional) Include extension of each file in the index file
Presets
If the filetype matches one of the presets, the values of prefix, suffix, and extension will use the preset values by default.
presets: {
pug: { prefix: `include `, suffix: ``, extension: false },
scss: { prefix: `@import '`, suffix: `';`, extension: false },
}