diff --git a/web/webpack.config.js b/web/webpack.config.js index 6a765e081..9945397a1 100644 --- a/web/webpack.config.js +++ b/web/webpack.config.js @@ -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),