clean dist folder when compiling
This commit is contained in:
parent
2e5cfe7a1e
commit
78d4efd8f3
1 changed files with 8 additions and 1 deletions
|
@ -20,11 +20,12 @@ const isProduction = process.env.NODE_ENV === 'production';
|
|||
const hasSentryToken = process.env.SENTRY_AUTH_TOKEN !== undefined;
|
||||
const jsBundleId = getJsBundleId();
|
||||
|
||||
// copy static files to dist file
|
||||
// copy static files to dist folder
|
||||
const copyWebpackCommands = [
|
||||
{
|
||||
from: `${STATIC_ROOT}/index-web.html`,
|
||||
to: `${DIST_ROOT}/index.html`,
|
||||
// add javascript script to index.html, generate/insert metatags
|
||||
transform(content, path) {
|
||||
return insertToHead(content.toString(), buildBasicOgMetadata());
|
||||
},
|
||||
|
@ -80,6 +81,12 @@ if (fs.existsSync(ROBOTS_TXT_PATH)) {
|
|||
});
|
||||
}
|
||||
|
||||
// clear the dist folder of existing js files before compilation
|
||||
let regex = /^.*\.(json|js|map)$/;
|
||||
fs.readdirSync(`${DIST_ROOT}/public/`)
|
||||
.filter(f => regex.test(f))
|
||||
.map(f => fs.unlinkSync(`${DIST_ROOT}/public/` + f));
|
||||
|
||||
let plugins = [
|
||||
new WriteFilePlugin(),
|
||||
new CopyWebpackPlugin(copyWebpackCommands),
|
||||
|
|
Loading…
Reference in a new issue