dist/lib/build.js
function generateIndex(opts, files, subDir) {
    if (subDir === void 0) { subDir = ''; }
    var shouldExport = opts.export;
    var isES6 = opts.es6;
    var content = '';
    var dirMap = {};
    switch (opts.ext) {
        case 'js':
            content += '/* eslint-disable */\n';
            break;
        case 'ts':
            content += '/* tslint:disable */\n';
            break;
    }
    files.forEach(function (file) {
        var name = path.basename(file).split('.')[0];
        var filePath = getFilePath(opts.sourcePath, file, subDir);
        var dir = filePath.split('/')[0];
        if (dir) {
            if (!dirMap[dir]) {
                dirMap[dir] = [];
                if (shouldExport) {
                    var dirName = camelcase_1.default(dir, {
                        pascalCase: true
                    });
                    content += isES6
                        ? "export * as  " + dirName + " from './" + dir + "'\n"
                        : "module.exports." + dirName + " = require('./" + dir + "')\n";
                }
                else {
                    content += isES6
                        ? "import './" + dir + "'\n"
                        : "require('./" + dir + "')\n";
                }
            }
            dirMap[dir].push(file);
        }
        else {
            if (shouldExport) {
                var fileName = camelcase_1.default(name, {
                    pascalCase: true
                });
                content += isES6
                    ? "export " + fileName + " from './" + filePath + name + "'\n"
                    : "module.exports." + fileName + " = require('./" + filePath + name + "')\n";
            }
            else {
                content += isES6
                    ? "import './" + filePath + name + "'\n"
                    : "require('./" + filePath + name + "')\n";
            }
        }
    });
    fs.writeFileSync(path.join(opts.targetPath, subDir, "index." + opts.ext), content, 'utf-8');
    console.log(colors.green("Generated " + (subDir ? subDir + path.sep : '') + "index." + opts.ext));
    // generate subDir index.js
    for (var dir in dirMap) {
        generateIndex(opts, dirMap[dir], path.join(subDir, dir));
    }
}
function generateIndex(opts, files, subDir) {
    if (subDir === void 0) { subDir = ''; }
    var shouldExport = opts.export;
    var isES6 = opts.es6;
    var content = '';
    var dirMap = {};
    switch (opts.ext) {
        case 'js':
            content += '/* eslint-disable */\n';
            break;
        case 'ts':
            content += '/* tslint:disable */\n';
            break;
    }
    files.forEach(function (file) {
        var name = path.basename(file).split('.')[0];
        var filePath = getFilePath(opts.sourcePath, file, subDir);
        var dir = filePath.split('/')[0];
        if (dir) {
            if (!dirMap[dir]) {
                dirMap[dir] = [];
                if (shouldExport) {
                    var dirName = camelcase_1.default(dir, {
                        pascalCase: true
                    });
                    content += isES6
                        ? "export * as  " + dirName + " from './" + dir + "'\n"
                        : "module.exports." + dirName + " = require('./" + dir + "')\n";
                }
                else {
                    content += isES6
                        ? "import './" + dir + "'\n"
                        : "require('./" + dir + "')\n";
                }
            }
            dirMap[dir].push(file);
        }
        else {
            if (shouldExport) {
                var fileName = camelcase_1.default(name, {
                    pascalCase: true
                });
                content += isES6
                    ? "export " + fileName + " from './" + filePath + name + "'\n"
                    : "module.exports." + fileName + " = require('./" + filePath + name + "')\n";
            }
            else {
                content += isES6
                    ? "import './" + filePath + name + "'\n"
                    : "require('./" + filePath + name + "')\n";
            }
        }
    });
    fs.writeFileSync(path.join(opts.targetPath, subDir, "index." + opts.ext), content, 'utf-8');
    console.log(colors.green("Generated " + (subDir ? subDir + path.sep : '') + "index." + opts.ext));
    // generate subDir index.js
    for (var dir in dirMap) {
        generateIndex(opts, dirMap[dir], path.join(subDir, dir));
    }
}
function generateIndex ( opts , files , subDir ) { if ( subDir === void 0 ) { subDir = '' ; } var shouldExport = opts . export ; var isES6 = opts . es6 ; var content = '' ; var dirMap = { } ; switch ( opts . ext ) { case 'js' : content += '/* eslint-disable */\n' ; break ; case 'ts' : content += '/* tslint:disable */\n' ; break ; } files . forEach ( function ( file ) { var name = path . basename ( file ) . split ( '.' ) [ 0 ] ; var filePath = getFilePath ( opts . sourcePath , file , subDir ) ; var dir = filePath . split ( '/' ) [ 0 ] ; if ( dir ) { if ( ! dirMap [ dir ] ) { dirMap [ dir ] = [ ] ; if ( shouldExport ) { var dirName = camelcase_1 . default ( dir , { pascalCase : true } ) ; content += isES6 ? "export * as  " + dirName + " from './" + dir + "'\n" : "module.exports." + dirName + " = require('./" + dir + "')\n" ; } else { content += isES6 ? "import './" + dir + "'\n" : "require('./" + dir + "')\n" ; } } dirMap [ dir ] . push ( file ) ; } else { if ( shouldExport ) { var fileName = camelcase_1 . default ( name , { pascalCase : true } ) ; content += isES6 ? "export " + fileName + " from './" + filePath + name + "'\n" : "module.exports." + fileName + " = require('./" + filePath + name + "')\n" ; } else { content += isES6 ? "import './" + filePath + name + "'\n" : "require('./" + filePath + name + "')\n" ; } } } ) ; fs . writeFileSync ( path . join ( opts . targetPath , subDir , "index." + opts . ext ) , content , 'utf-8' ) ; console . log ( colors . green ( "Generated " + ( subDir ? subDir + path . sep : '' ) + "index." + opts . ext ) ) ; // generate subDir index.js for ( var dir in dirMap ) { generateIndex ( opts , dirMap [ dir ] , path . join ( subDir , dir ) ) ; } }
generate index.js, which import all icons
generate index . js which import all icons