From dec61e61a39e0c7be9d6a3d4de7de95a49093572 Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 15 Apr 2020 10:56:42 -0600 Subject: [PATCH] Extern some more libs to save on js bundle size --- webpack.config.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 84c0fd276..c7b688b64 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -130,13 +130,24 @@ module.exports = { hot: true, liveReload: false, }, - externals: { - 'jquery': 'jQuery', - 'cheerio': 'window', - 'react/addons': true, - 'react/lib/ExecutionEnvironment': true, - 'react/lib/ReactContext': true, - }, + externals: Object.assign( + {}, + { + 'jquery': 'jQuery', + 'cheerio': 'window', + 'react/addons': true, + 'react/lib/ExecutionEnvironment': true, + 'react/lib/ReactContext': true, + moment: 'moment', + lodash: 'lodash', + // WordPress components are too heavy to extern because we only use a few components. + }, + ! isDev ? { + // Dev mode cannot use external react-dom because HMR requires patched @hot-loader/react-dom + react: 'React', + 'react-dom': 'ReactDOM', + } : undefined + ), module: { rules: [ {