feat(v2): ️ faster and lighter bundle size (optimization) (#1681)

* feat(v2):️  fasterr and lighter bundle size optimization

* lint

* nits
This commit is contained in:
Endi 2019-07-20 16:55:24 +07:00 committed by GitHub
parent 7f5c1ef581
commit 1f0f3e130b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 43 deletions

View file

@ -8,12 +8,11 @@
},
"license": "MIT",
"dependencies": {
"@philpl/buble": "^0.19.7",
"classnames": "^2.2.6",
"clipboard": "^2.0.4",
"prism-react-renderer": "^0.1.7",
"react-live": "^2.1.2",
"react-loadable": "^5.5.0",
"react-loadable-visibility": "^3.0.1"
"react-live": "^2.1.2"
},
"peerDependencies": {
"@docusaurus/core": "^2.0.0",

View file

@ -14,5 +14,17 @@ module.exports = function() {
getThemePath() {
return path.resolve(__dirname, './theme');
},
configureWebpack() {
return {
resolve: {
alias: {
// fork of Buble which removes Buble's large dependency and weighs in at a smaller size of ~51kB
// https://github.com/FormidableLabs/react-live#what-bundle-size-can-i-expect
buble: '@philpl/buble',
},
},
};
},
};
};

View file

@ -7,22 +7,13 @@
import React, {useEffect, useState, useRef} from 'react';
import classnames from 'classnames';
import LoadableVisibility from 'react-loadable-visibility/react-loadable';
import Highlight, {defaultProps} from 'prism-react-renderer';
import nightOwlTheme from 'prism-react-renderer/themes/nightOwl';
import Clipboard from 'clipboard';
import Loading from '@theme/Loading';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Playground from '@theme/Playground';
import styles from './styles.module.css';
/* Live playground is not small in size, lazy load it is better */
const Playground = LoadableVisibility({
loader: () => import('@theme/Playground'),
loading: Loading,
modules: ['@theme/Playground'],
webpack: () => [require.resolveWeak('@theme/Playground')],
});
export default ({children, className: languageClassName, live, ...props}) => {
const {
siteConfig: {