0.3.7 • Published 2 years ago

auto-export v0.3.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

auto-export

A cli can automatically export files

NPM version

Why

When you want to export many files of the same type in one folder, you may cost a lot of time to copy and paste the same code. eg if you want to export all imagesin one folder, you need to copy and paste the same code for each image, and export these images in a index.ts file.Why not have a try to use auto-export👻

🚀 Features

  • Multiple directory generate support
  • Nested directory generate support
  • Custom output directory support
  • Custom import statement support
  • Auto Prefix support

Usage

Install

pnpm add -D auto-export

Config export.config.ts

  • targetDir (require) : the directory to export files

  • outputDir (optional,default targetDir) : the directory to generate the index.ts file to export files

  • customImport (optional) : custom the import statement to use in the index.ts file

  • depth (optional , default true) : traverse all subdirectories

  • autoPrefix (optional , default false) : auto add prefix to the file name. Note that the if you open the customImport option,this option will be ignored

import { defineExportConfig } from 'auto-export'
export default defineExportConfig({
  configs: [
    {
      targetDir: './src/assets/images',
    },
    {
      targetDir: './src/assets/img',
      depth: true,
      autoPrefix: true
    },
    {
      targetDir: './src/assets/css',
      outputDir: './src/assets/css',
    },
    {
      targetDir: './src/assets/svgs',
      customImport: (fileName, file) => {
        return `import { ReactComponent as ${fileName} } from '${file}'`
      },
    },
    {
      targetDir: './src/assets/gif',
      customImport: (fileName, file, fileType) => {
        return `import ${fileType}${fileName} from '${file}'`
      },
      depth: true
    },
  ],
})

Generate index.ts

pnpm run autoexport

Author

sudongyuer email:976499226@qq.com

License

MIT License © 2021 SuDongYu

0.1.0

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.1.1

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.2.6

2 years ago

0.3.7

2 years ago

0.3.2

2 years ago

0.2.3

2 years ago

0.3.1

2 years ago

0.2.2

2 years ago

0.3.4

2 years ago

0.2.5

2 years ago

0.3.3

2 years ago

0.2.4

2 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.1.1

5 years ago