我可以使用 webpack 使用配置文件一次转换多个 .epub 文件吗?如何转换?
Can I use webpack to convert multiple .epub files at once using config file and how?
var fs= require('fs');
var epubZip= require('epub-zip');
var content = epubZip('./tests/epubs/epub1');
var content2= epubZip('./tests/epubs/epub2');
fs.writeFileSync("./tests/dist/epub1.epub",content);
fs.writeFileSync("./tests/dist/epub2.epub",content2);
例如,这是用于生成 2 个 epub 文件的代码,我如何仅通过编写一个 fs.writeFileSync 函数就可以自动获得多个输出。
function getDirectories(mypath) {
return fs.readdirSync(mypath).filter(function(file) {
if(fs.statSync(path.join(mypath, file)).isDirectory()) {
//console.log('mypath is :',file);
var newpath = mypath+'/'+file;
//console.log('newpath is:'+newpath);
var content =epubZip(newpath);
var writepath=mywritepath+'/'+file+'.epub';
//console.log('writepath is:'+writepath);
fs.writeFileSync(writepath,content);
}
这就是我解决问题的方法,将我的目录名称附加到路径
var fs= require('fs');
var epubZip= require('epub-zip');
var content = epubZip('./tests/epubs/epub1');
var content2= epubZip('./tests/epubs/epub2');
fs.writeFileSync("./tests/dist/epub1.epub",content);
fs.writeFileSync("./tests/dist/epub2.epub",content2);
例如,这是用于生成 2 个 epub 文件的代码,我如何仅通过编写一个 fs.writeFileSync 函数就可以自动获得多个输出。
function getDirectories(mypath) {
return fs.readdirSync(mypath).filter(function(file) {
if(fs.statSync(path.join(mypath, file)).isDirectory()) {
//console.log('mypath is :',file);
var newpath = mypath+'/'+file;
//console.log('newpath is:'+newpath);
var content =epubZip(newpath);
var writepath=mywritepath+'/'+file+'.epub';
//console.log('writepath is:'+writepath);
fs.writeFileSync(writepath,content);
}
这就是我解决问题的方法,将我的目录名称附加到路径