From 2464de188897eaac9b3b91439d4be3dace57cde6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Wed, 25 Dec 2019 17:15:35 +0800 Subject: [PATCH] perf: optimize bundlesize (#20436) * :package: react-slick => @ant-design/react-slick * :package: Reduce non-minified dist files size * :up: @ant-design/react-slick --- components/carousel/index.tsx | 4 ++-- package.json | 3 +-- webpack.config.js | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/carousel/index.tsx b/components/carousel/index.tsx index 3f695a0b4e..b2535af642 100644 --- a/components/carousel/index.tsx +++ b/components/carousel/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import debounce from 'lodash/debounce'; -import { Settings } from 'react-slick'; +import { Settings } from '@ant-design/react-slick'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import warning from '../_util/warning'; @@ -8,7 +8,7 @@ import warning from '../_util/warning'; // make sure matchMedia polyfill run before require('react-slick') // Fix https://github.com/ant-design/ant-design/issues/6560 // Fix https://github.com/ant-design/ant-design/issues/3308 -const SlickCarousel = require('react-slick').default; +const SlickCarousel = require('@ant-design/react-slick').default; export type CarouselEffect = 'scrollx' | 'fade'; export type DotPosition = 'top' | 'bottom' | 'left' | 'right'; diff --git a/package.json b/package.json index 7de046834a..7800fd21ee 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,6 @@ ], "dependencies": { "@ant-design/icons": "^4.0.0-alpha.11", - "@types/react-slick": "^0.23.4", "array-tree-filter": "^2.1.0", "classnames": "~2.2.6", "copy-to-clipboard": "^3.2.0", @@ -131,7 +130,7 @@ "rc-upload": "~3.0.0-alpha.0", "rc-util": "~4.16.1", "rc-virtual-list": "^0.0.0-alpha.25", - "react-slick": "~0.25.2", + "@ant-design/react-slick": "~0.25.5", "resize-observer-polyfill": "^1.5.1", "scroll-into-view-if-needed": "^2.2.20", "shallowequal": "^1.1.0", diff --git a/webpack.config.js b/webpack.config.js index ddb56abb1e..22340c936d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -49,6 +49,8 @@ if (process.env.RUN_ENV === 'PRODUCTION') { externalMoment(config); addLocales(config); addDarkTheme(config); + // Reduce non-minified dist files size + config.optimization.usedExports = true; // skip codesandbox ci if (!process.env.CSB_REPO) { // https://docs.packtracker.io/uploading-your-webpack-stats/webpack-plugin