index.js
function (_a) {
    var _b = _a === void 0 ? {} : _a, baseDir = _b.baseDir, _c = _b.fontsPathToSave, fontsPathToSave = _c === void 0 ? process.cwd() + "/build/static/fonts/" : _c, _d = _b.iconUrl, iconUrl = _d === void 0 ? "https://at.alicdn.com/t/" : _d, _e = _b.fontReg, fontReg = _e === void 0 ? /@font-face{font-family:anticon;src:url(.*)}$/g : _e, _f = _b.urlReg, urlReg = _f === void 0 ? reg : _f, _g = _b.cssPath, cssPath = _g === void 0 ? process.cwd() + "/build/static/css/" : _g, _h = _b.newFontsPath, newFontsPath = _h === void 0 ? "/static/fonts/" : _h;
    if (baseDir !== "") {
        fontsPathToSave = getPath(baseDir, fontsPathToSave);
        cssPath = getPath(baseDir, cssPath);
    }
    return exports.finder(cssPath, function (content, filePath) {
        var cssContents = content.toString();
        var m = cssContents.match(urlReg);
        if (m) {
            // create fonts folder if not exists
            if (!fs.existsSync(fontsPathToSave)) {
                fs.mkdir(fontsPathToSave, function (err) {
                    if (err) {
                        throw err;
                    }
                    console.log("mkdir " + fontsPathToSave + " success");
                });
            }
            m.forEach(function (item) {
                var itemInfo = path.parse(item);
                var shortname = itemInfo.base.replace(/((\?|#).*)/g, "");
                exports.downloader(item, fontsPathToSave + "/" + shortname, function (err, c) {
                    if (err) {
                        throw err;
                    }
                    var replacedContents = cssContents.replace(new RegExp(iconUrl, "gi"), newFontsPath);
                    fs.writeFile(filePath, replacedContents, function (err) {
                        if (err) {
                            throw err;
                        }
                        console.log("replace " + shortname + " done.");
                    });
                });
            });
        }
        else {
            console.log("no results founded.");
        }
    });
}
function (_a) {
    var _b = _a === void 0 ? {} : _a, baseDir = _b.baseDir, _c = _b.fontsPathToSave, fontsPathToSave = _c === void 0 ? process.cwd() + "/build/static/fonts/" : _c, _d = _b.iconUrl, iconUrl = _d === void 0 ? "https://at.alicdn.com/t/" : _d, _e = _b.fontReg, fontReg = _e === void 0 ? /@font-face{font-family:anticon;src:url(.*)}$/g : _e, _f = _b.urlReg, urlReg = _f === void 0 ? reg : _f, _g = _b.cssPath, cssPath = _g === void 0 ? process.cwd() + "/build/static/css/" : _g, _h = _b.newFontsPath, newFontsPath = _h === void 0 ? "/static/fonts/" : _h;
    if (baseDir !== "") {
        fontsPathToSave = getPath(baseDir, fontsPathToSave);
        cssPath = getPath(baseDir, cssPath);
    }
    return exports.finder(cssPath, function (content, filePath) {
        var cssContents = content.toString();
        var m = cssContents.match(urlReg);
        if (m) {
            // create fonts folder if not exists
            if (!fs.existsSync(fontsPathToSave)) {
                fs.mkdir(fontsPathToSave, function (err) {
                    if (err) {
                        throw err;
                    }
                    console.log("mkdir " + fontsPathToSave + " success");
                });
            }
            m.forEach(function (item) {
                var itemInfo = path.parse(item);
                var shortname = itemInfo.base.replace(/((\?|#).*)/g, "");
                exports.downloader(item, fontsPathToSave + "/" + shortname, function (err, c) {
                    if (err) {
                        throw err;
                    }
                    var replacedContents = cssContents.replace(new RegExp(iconUrl, "gi"), newFontsPath);
                    fs.writeFile(filePath, replacedContents, function (err) {
                        if (err) {
                            throw err;
                        }
                        console.log("replace " + shortname + " done.");
                    });
                });
            });
        }
        else {
            console.log("no results founded.");
        }
    });
}
function ( _a ) { var _b = _a === void 0 ? { } : _a , baseDir = _b . baseDir , _c = _b . fontsPathToSave , fontsPathToSave = _c === void 0 ? process . cwd ( ) + "/build/static/fonts/" : _c , _d = _b . iconUrl , iconUrl = _d === void 0 ? "https://at.alicdn.com/t/" : _d , _e = _b . fontReg , fontReg = _e === void 0 ? / @font-face{font-family:anticon;src:url(.*)}$ / g : _e , _f = _b . urlReg , urlReg = _f === void 0 ? reg : _f , _g = _b . cssPath , cssPath = _g === void 0 ? process . cwd ( ) + "/build/static/css/" : _g , _h = _b . newFontsPath , newFontsPath = _h === void 0 ? "/static/fonts/" : _h ; if ( baseDir !== "" ) { fontsPathToSave = getPath ( baseDir , fontsPathToSave ) ; cssPath = getPath ( baseDir , cssPath ) ; } return exports . finder ( cssPath , function ( content , filePath ) { var cssContents = content . toString ( ) ; var m = cssContents . match ( urlReg ) ; if ( m ) { // create fonts folder if not exists if ( ! fs . existsSync ( fontsPathToSave ) ) { fs . mkdir ( fontsPathToSave , function ( err ) { if ( err ) { throw err ; } console . log ( "mkdir " + fontsPathToSave + " success" ) ; } ) ; } m . forEach ( function ( item ) { var itemInfo = path . parse ( item ) ; var shortname = itemInfo . base . replace ( / ((\?|#).*) / g , "" ) ; exports . downloader ( item , fontsPathToSave + "/" + shortname , function ( err , c ) { if ( err ) { throw err ; } var replacedContents = cssContents . replace ( new RegExp ( iconUrl , "gi" ) , newFontsPath ) ; fs . writeFile ( filePath , replacedContents , function ( err ) { if ( err ) { throw err ; } console . log ( "replace " + shortname + " done." ) ; } ) ; } ) ; } ) ; } else { console . log ( "no results founded." ) ; } } ) ; }
finding files and replace it
finding files and replace it