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