0.9.0 • Published 4 years ago

named-exports v0.9.0

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

named-exports

Generates named exports in real time from one or more directories.

Getting Started

To begin, you'll need to install named-exports:

$ npm install named-exports --save-dev

Se você quer exportar arquivos dentro da pasta de componentes

├── src
│   └── components
│       ├── ButtonStyled.vue
│       ├── InputStyled.vue
│       └── ...
...

Then add the plugin to your webpack config. For example:

webpack.config.js

const NamedExports = require('named-exports')

module.exports = {
  plugins: [
    new NamedExports({
      patterns: [
        {
          paths: ['src/components']
        }
      ]
    })
  ]
}

Result:

src/components/index.js
export { default as ButtonStyled } from './ButtonStyled.vue'
export { default as InputStyled } from './InputStyled.vue'
// ..

Options

const NamedExports = require('named-exports')

module.exports = {
  plugins: [
    new NamedExports({
      patterns: [
        {
          basePath: 'src',
          paths: ['components/**/', 'store/**', 'utils'],
          includeFolders: true,
          indexOfFolders: 'index.vue',
          ignore: ['*.css'],
          output: {
            filename: 'index.ts',
            comment: true,
            semi: true,
            singleQuote: true,
            finalNewLine: false
          }
        }
      ]
    })
  ]
}

Pattern

NameTypeDefaultDescription
basePath{String}undefinedBase for all paths, the goal is to avoid repetition.
paths{Array}undefinedAll target paths that need an export file.
includeFolders{Boolean}falseDetermines whether to include folders in exports.
indexOfFolders{String}undefinedsometimes index.js is not an index of a folder we want to export, so use this property to define.
ignore{Array}['.DS_Store']Files or folders to be ignored.
output.filename{String}index.jsName of the export file that will be generated in each defined path.
output.comment{Boolean\|String}falseComment to make it explicit that the file was automatically generated by a plugin.
output.semi{Boolean}falsePut semicolons at the end of each export.
output.singleQuote{Boolean}trueUse single quotes in the export code
output.finalNewLine{Boolean}trueInsert a blank line at the end of the export file, just to maintain the beauty standard of your app.

ℹ️ If you need exports with different settings in another folder, you can add as many patterns as you want.

ℹ️ named-exports is not designed to exports files generated from the build process; rather, it is to exports files that already exist in the source tree, as part of the build process.

Documentation

Read the documentation and demos.

License

MIT

0.9.0

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago