clear stale js files on nonprod environments
This commit is contained in:
parent
a422e857e3
commit
0ef61fc575
1 changed files with 9 additions and 0 deletions
|
@ -77,6 +77,15 @@ if (fs.existsSync(CUSTOM_OG_PATH)) {
|
|||
});
|
||||
}
|
||||
|
||||
// clear the dist folder of existing js files before compilation
|
||||
let regex = /^.*\.(json|js|map)$/;
|
||||
// only run on nonprod environments to avoid side effects on prod
|
||||
if (!isProduction) {
|
||||
fs.readdirSync(`${DIST_ROOT}/public/`)
|
||||
.filter(f => regex.test(f))
|
||||
.map(f => fs.unlinkSync(`${DIST_ROOT}/public/` + f));
|
||||
}
|
||||
|
||||
const ROBOTS_TXT_PATH = `${CUSTOM_ROOT}/robots.txt`;
|
||||
if (fs.existsSync(ROBOTS_TXT_PATH)) {
|
||||
copyWebpackCommands.push({
|
||||
|
|
Loading…
Add table
Reference in a new issue