A cli can automatically export files
npm install auto-exportA cli can automatically export files


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 images in 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👻
``ball`
pnpm add -D auto-export
- 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
`jsimport { ReactComponent as ${fileName} } from '${file}'
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 ${fileType}${fileName} from '${file}'
},
},
{
targetDir: './src/assets/gif',
customImport: (fileName, file, fileType) => {
return
},
depth: true
},
],
})
`
`bash``
pnpm run autoexport
sudongyuer email:976499226@qq.com