mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 18:27:56 +02:00
feat(v2): better splitchunks and babel default (#1653)
* feat(v2): better splitchunks and babel default * common chunks * chunks: all
This commit is contained in:
parent
9e9ad1f2b8
commit
22ce04d3fb
4 changed files with 23 additions and 19 deletions
|
@ -10,10 +10,10 @@
|
|||
"dependencies": {
|
||||
"classnames": "^2.2.6",
|
||||
"clipboard": "^2.0.4",
|
||||
"prism-react-renderer": "^0.1.6",
|
||||
"prism-react-renderer": "^0.1.7",
|
||||
"react-live": "^2.1.2",
|
||||
"react-loadable": "^5.5.0",
|
||||
"react-loadable-visibility": "^2.5.1"
|
||||
"react-loadable-visibility": "^3.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@docusaurus/core": "^2.0.0",
|
||||
|
|
|
@ -18,6 +18,8 @@ import styles from './styles.module.css';
|
|||
const Playground = LoadableVisibility({
|
||||
loader: () => import('@theme/Playground'),
|
||||
loading: Loading,
|
||||
modules: ['@theme/Playground'],
|
||||
webpack: () => [require.resolveWeak('@theme/Playground')],
|
||||
});
|
||||
|
||||
export default ({children, className: languageClassName, live, ...props}) => {
|
||||
|
|
|
@ -28,8 +28,10 @@ export function createBaseConfig(
|
|||
baseUrl,
|
||||
generatedFilesDir,
|
||||
cliOptions: {cacheLoader},
|
||||
routesPaths,
|
||||
} = props;
|
||||
|
||||
const totalPages = routesPaths.length;
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
return {
|
||||
mode: isProd ? 'production' : 'development',
|
||||
|
@ -89,6 +91,12 @@ export function createBaseConfig(
|
|||
cacheGroups: {
|
||||
// disable the built-in cacheGroups
|
||||
default: false,
|
||||
common: {
|
||||
name: 'common',
|
||||
chunks: 'all',
|
||||
minChunks: totalPages > 2 ? totalPages * 0.5 : 2,
|
||||
priority: 40,
|
||||
},
|
||||
vendor: {
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
priority: 30,
|
||||
|
@ -110,13 +118,6 @@ export function createBaseConfig(
|
|||
// create chunk regardless of the size of the chunk
|
||||
enforce: true,
|
||||
},
|
||||
common: {
|
||||
name: 'common',
|
||||
minChunks: 2,
|
||||
priority: 10,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -124,12 +125,8 @@ export function createBaseConfig(
|
|||
rules: [
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
exclude: modulePath => {
|
||||
// Don't transpile node_modules except any docusaurus package
|
||||
return (
|
||||
/node_modules/.test(modulePath) && !/docusaurus/.test(modulePath)
|
||||
);
|
||||
},
|
||||
include: [siteDir, /docusaurus/],
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
cacheLoader && getCacheLoader(isServer),
|
||||
getBabelLoader(isServer),
|
||||
|
|
13
yarn.lock
13
yarn.lock
|
@ -11303,6 +11303,11 @@ prism-react-renderer@^0.1.0, prism-react-renderer@^0.1.6:
|
|||
resolved "https://registry.yarnpkg.com/prism-react-renderer/-/prism-react-renderer-0.1.6.tgz#c9216baa234fab1c234209fcdaf0cd23a01c50a9"
|
||||
integrity sha512-uZJn5wrygCH0ZMue+2JRd0qJharrmpxa6/uK7deKgvCtJFFE+VsyvJ49LS8/ATt0mlAJS6vFQTDvhXBEXsda+A==
|
||||
|
||||
prism-react-renderer@^0.1.7:
|
||||
version "0.1.7"
|
||||
resolved "https://registry.yarnpkg.com/prism-react-renderer/-/prism-react-renderer-0.1.7.tgz#dc273d0cb6e4a498ba0775094e9a8b01a3ad2eaa"
|
||||
integrity sha512-EhnM0sYfLK103ASK0ViSv0rta//ZGB0dBA9TiFyOvA+zOj5peLmGEG01sLEDwl9sMe+gSqncInafBe1VFTCMvA==
|
||||
|
||||
prismjs@^1.15.0:
|
||||
version "1.16.0"
|
||||
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.16.0.tgz#406eb2c8aacb0f5f0f1167930cb83835d10a4308"
|
||||
|
@ -11735,10 +11740,10 @@ react-loadable-ssr-addon@^0.1.8:
|
|||
resolved "https://registry.yarnpkg.com/react-loadable-ssr-addon/-/react-loadable-ssr-addon-0.1.9.tgz#c134275fd36637a554f6438a0b78e0d1f70a8260"
|
||||
integrity sha512-mjk0ykDmmgPvkoFVwjbhev/VtarlpdR7B9FzuFFxtviFWVjaL8ddw4J89uFvUkC1KtFmXdQ6BF7yzUB54QqmXg==
|
||||
|
||||
react-loadable-visibility@^2.5.1:
|
||||
version "2.5.1"
|
||||
resolved "https://registry.yarnpkg.com/react-loadable-visibility/-/react-loadable-visibility-2.5.1.tgz#713ad70967865a0db1f4dc918228a29a59a593d5"
|
||||
integrity sha512-rIwqjznjAi7i9K+BF/SUCcQZaiIhoPbbMj9aLceHeH093kL4aJ0bdj/iUG6E+ohIkKliKgKB2RKSai0MwNH51g==
|
||||
react-loadable-visibility@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/react-loadable-visibility/-/react-loadable-visibility-3.0.1.tgz#ab1e005ff4cf0551b28f5437d93d56d70fdfc9ef"
|
||||
integrity sha512-DabYmhhu+ejoIfIOu0F5YjDgZQznBePTeIszICh6GCdfzFK6sYU9sdlxdjOlNnfxGzF4yRh/+YIl2ktJ/WB8xg==
|
||||
|
||||
react-loadable@^5.5.0:
|
||||
version "5.5.0"
|
||||
|
|
Loading…
Add table
Reference in a new issue