From c9ed7351396aa0ecf88ceb931dd99bec1041fe47 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Thu, 25 Apr 2019 09:08:15 +0800 Subject: [PATCH] removeExceptGitDir --- public/react/scripts/build.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/public/react/scripts/build.js b/public/react/scripts/build.js index eb5bcbae..cf7c1377 100644 --- a/public/react/scripts/build.js +++ b/public/react/scripts/build.js @@ -43,13 +43,29 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { process.exit(1); } +function removeExceptGitDir(dir) { + fs2.readdir(dir, function(err, list) { + if (err) return done(err); + var pending = list.length; + if (!pending) return done(null, results); + list.forEach(function(file) { + if (file.indexOf('.git') == -1) { + file = path.resolve(dir, file); + fs.remove(file) + } + }); + }); +} + // First, read the current file sizes in build directory. // This lets us display how much they changed later. measureFileSizesBeforeBuild(paths.appBuild) .then(previousFileSizes => { // Remove all content but keep the directory so that // if you're in it, you don't end up in Trash - fs.emptyDirSync(paths.appBuild); + // fs.emptyDirSync(paths.appBuild); + removeExceptGitDir(paths.appBuild) + // Merge with the public folder copyPublicFolder(); // Start the webpack build