From 7548ddcbc51d52a4eaffe88d1076aa58f8f00fd9 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Sat, 26 Aug 2017 01:54:10 +0200 Subject: [PATCH] Alias react to preact in static builds. --- webpack.config.babel.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/webpack.config.babel.js b/webpack.config.babel.js index 23b553b..2840dcb 100644 --- a/webpack.config.babel.js +++ b/webpack.config.babel.js @@ -390,11 +390,6 @@ export default (options) => { '.js', '.json', '.jsx', ], alias: { - // Use preact instead of react - /* react: 'preact-compat\\dist\\preact-compat', - 'react-dom': 'preact-compat\\dist\\preact-compat', - 'create-react-class': 'preact-compat/lib/create-react-class', */ - 'moment-timezone': 'moment-timezone/builds/moment-timezone-with-data-2012-2022.js', }, }, @@ -413,4 +408,15 @@ export default (options) => { ], }, }; + + if (!server) { + // Use preact instead of react (only on static build) + Object.assign(config.resolve.alias, { + react: !server ? 'preact-compat\\dist\\preact-compat' : undefined, + 'react-dom': !server ? 'preact-compat\\dist\\preact-compat' : undefined, + 'create-react-class': !server ? 'preact-compat/lib/create-react-class' : undefined, + }); + } + + return config; };