mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-29 00:47:03 +02:00
feat(v2): ⚡️ faster and lighter bundle size (optimization) (#1681)
* feat(v2):⚡️ fasterr and lighter bundle size optimization
* lint
* nits
This commit is contained in:
parent
7f5c1ef581
commit
1f0f3e130b
5 changed files with 55 additions and 43 deletions
|
@ -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",
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue