From 9cc789848df5342f1fd39f2c3d016ca7a78ff409 Mon Sep 17 00:00:00 2001 From: Joshua Stephen Date: Thu, 30 Jul 2020 09:13:19 +0700 Subject: [PATCH] feat: add pdp chunk & optimize moment plugin --- client/routes/PDP/index.js | 17 ++++++----------- tools/client/webpack.config.babel.js | 2 ++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/client/routes/PDP/index.js b/client/routes/PDP/index.js index bad7cab..cdbde74 100644 --- a/client/routes/PDP/index.js +++ b/client/routes/PDP/index.js @@ -1,14 +1,9 @@ -import React from 'react'; -import { object } from 'prop-types'; +import loadable from '@loadable/component'; -import PdpComponent from './components'; +const errorLoading = err => console.log('PDP page loading failed!', err); -const PDP = ({ match }) => { - return () -}; +const PDPComponent = loadable(() => + import(/* webpackChunkName: "pdp" */ './components').catch(errorLoading), +); -PDP.propTypes = { - match: object.isRequired, -}; - -export default PDP; +export default PDPComponent; diff --git a/tools/client/webpack.config.babel.js b/tools/client/webpack.config.babel.js index 19ca824..fd44473 100644 --- a/tools/client/webpack.config.babel.js +++ b/tools/client/webpack.config.babel.js @@ -406,6 +406,8 @@ module.exports = function() { color: '#61dafb', }), + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), + new FriendlyErrorsWebpackPlugin(), // Generates an `index.html` or `index.client.html` file with the