webpack-plugin-deletecompilerbundle
Advanced tools
+22
-18
@@ -37,24 +37,28 @@ import * as path from 'path'; | ||
| // 判断是不是文件夹 | ||
| const fileStats = fs.statSync(folderPath); | ||
| try { | ||
| const fileStats = fs.statSync(folderPath); | ||
| // 文件夹删除 | ||
| if (fileStats.isDirectory()) { | ||
| if (fs.existsSync(folderPath)) { | ||
| try { | ||
| fs.rmSync(folderPath, { recursive: true, force: true }); | ||
| // 文件夹删除 | ||
| if (fileStats.isDirectory()) { | ||
| if (fs.existsSync(folderPath)) { | ||
| try { | ||
| fs.rmSync(folderPath, { recursive: true, force: true }); | ||
| console.log(`\x1b[42;30m 删除文件夹成功: ${folderPath} \x1b[0m`); | ||
| } catch (error) { | ||
| console.log(`\x1b[41;30m 删除文件夹失败 ----> ${folderPath} \x1b[0m`); | ||
| console.log(`\x1b[42;30m 删除文件夹成功: ${folderPath} \x1b[0m`); | ||
| } catch (error) { | ||
| console.log(`\x1b[41;30m 删除文件夹失败 ----> ${folderPath} \x1b[0m`); | ||
| } | ||
| } | ||
| } else { | ||
| // 文件删除 | ||
| const sourcePath = path.join(stats.compilation.compiler.outputPath, itemFolder); | ||
| try { | ||
| fs.unlinkSync(sourcePath); | ||
| console.log(`\x1b[42;30m 删除文件夹成功: ${sourcePath} \x1b[0m`); | ||
| } catch { | ||
| console.log(`\x1b[41;30m 删除文件失败 ----> ${sourcePath} \x1b[0m`); | ||
| } | ||
| } | ||
| } else { | ||
| // 文件删除 | ||
| const sourcePath = path.join(stats.compilation.compiler.outputPath, itemFolder); | ||
| try { | ||
| fs.unlinkSync(sourcePath); | ||
| console.log(`\x1b[42;30m 删除文件夹成功: ${sourcePath} \x1b[0m`); | ||
| } catch { | ||
| console.log(`\x1b[41;30m 删除文件失败 ----> ${sourcePath} \x1b[0m`); | ||
| } | ||
| } catch { | ||
| console.log(`\x1b[41;30m 执行异常 \x1b[0m`); | ||
| } | ||
@@ -61,0 +65,0 @@ } |
+1
-1
| { | ||
| "name": "webpack-plugin-deletecompilerbundle", | ||
| "version": "1.2.0", | ||
| "version": "1.2.1", | ||
| "description": "webpack plugin delete compiler bundle", | ||
@@ -5,0 +5,0 @@ "author": "gzh <18255106634@163.com>", |
10232
2.37%167
2.45%