-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
162 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,8 @@ | |
"webpack": "npm:@rspack/[email protected]" | ||
}, | ||
"patchedDependencies": { | ||
"@docusaurus/[email protected]": "patches/@[email protected]" | ||
"@docusaurus/[email protected]": "patches/@[email protected]", | ||
"@docusaurus/[email protected]": "patches/@[email protected]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
diff --git a/lib/client/docusaurus.js b/lib/client/docusaurus.js | ||
index 0f105f5ed17aac0b942e855230454b0e53730052..1e17ee8eb35cbbbc4cb38a062a73e6128c74e862 100644 | ||
--- a/lib/client/docusaurus.js | ||
+++ b/lib/client/docusaurus.js | ||
@@ -34,16 +34,16 @@ const prefetch = (routePath) => { | ||
const chunkNamesNeeded = matches.flatMap((match) => getChunkNamesToLoad(match.route.path)); | ||
// Prefetch all webpack chunk assets file needed. | ||
return Promise.all(chunkNamesNeeded.map((chunkName) => { | ||
- // "__webpack_require__.gca" is injected by ChunkAssetPlugin. Pass it | ||
- // the name of the chunk you want to load and it will return its URL. | ||
- // eslint-disable-next-line camelcase | ||
- const chunkAsset = __webpack_require__.gca(chunkName); | ||
- // In some cases, webpack might decide to optimize further, leading to | ||
- // the chunk assets being merged to another chunk. In this case, we can | ||
- // safely filter it out and don't need to load it. | ||
- if (chunkAsset && !chunkAsset.includes('undefined')) { | ||
- return prefetchHelper(chunkAsset); | ||
- } | ||
+ // // "__webpack_require__.gca" is injected by ChunkAssetPlugin. Pass it | ||
+ // // the name of the chunk you want to load and it will return its URL. | ||
+ // // eslint-disable-next-line camelcase | ||
+ // const chunkAsset = __webpack_require__.gca(chunkName); | ||
+ // // In some cases, webpack might decide to optimize further, leading to | ||
+ // // the chunk assets being merged to another chunk. In this case, we can | ||
+ // // safely filter it out and don't need to load it. | ||
+ // if (chunkAsset && !chunkAsset.includes('undefined')) { | ||
+ // return prefetchHelper(chunkAsset); | ||
+ // } | ||
return Promise.resolve(); | ||
})); | ||
}; | ||
diff --git a/lib/webpack/base.js b/lib/webpack/base.js | ||
index db4f893ea45f9e694361c6452f035673f14605df..1e0034d3dac95416715d7aebd3590a26005b9c7b 100644 | ||
--- a/lib/webpack/base.js | ||
+++ b/lib/webpack/base.js | ||
@@ -10,11 +10,13 @@ exports.createBaseConfig = exports.excludeJS = exports.clientDir = void 0; | ||
const tslib_1 = require("tslib"); | ||
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra")); | ||
const path_1 = tslib_1.__importDefault(require("path")); | ||
-const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin")); | ||
+const mini_css_extract_plugin = require('webpack').CssExtractRspackPlugin; | ||
const utils_1 = require("@docusaurus/utils"); | ||
const utils_2 = require("./utils"); | ||
const minification_1 = require("./minification"); | ||
const aliases_1 = require("./aliases"); | ||
+const webpack = require('webpack'); | ||
+ | ||
const CSS_REGEX = /\.css$/i; | ||
const CSS_MODULE_REGEX = /\.module\.css$/i; | ||
exports.clientDir = path_1.default.join(__dirname, '..', 'client'); | ||
@@ -196,8 +198,11 @@ async function createBaseConfig({ props, isServer, minify, }) { | ||
}, | ||
], | ||
}, | ||
+ experiments: { | ||
+ css:false | ||
+ }, | ||
plugins: [ | ||
- new mini_css_extract_plugin_1.default({ | ||
+ new mini_css_extract_plugin({ | ||
filename: isProd | ||
? 'assets/css/[name].[contenthash:8].css' | ||
: '[name].css', | ||
@@ -209,7 +214,8 @@ async function createBaseConfig({ props, isServer, minify, }) { | ||
// for more reasoning | ||
ignoreOrder: true, | ||
}), | ||
- ], | ||
+ | ||
+ ] | ||
}; | ||
} | ||
exports.createBaseConfig = createBaseConfig; | ||
diff --git a/lib/webpack/client.js b/lib/webpack/client.js | ||
index ff364813e24f527a90ad82fa097ef6ccd873828f..6eb6b597a1a8775fe55d010594cdca44a1c0d8c3 100644 | ||
--- a/lib/webpack/client.js | ||
+++ b/lib/webpack/client.js | ||
@@ -22,7 +22,7 @@ const ForceTerminatePlugin_1 = tslib_1.__importDefault(require("./plugins/ForceT | ||
const StaticDirectoriesCopyPlugin_1 = require("./plugins/StaticDirectoriesCopyPlugin"); | ||
async function createBaseClientConfig({ props, hydrate, minify, }) { | ||
const baseConfig = await (0, base_1.createBaseConfig)({ props, isServer: false, minify }); | ||
- return (0, webpack_merge_1.default)(baseConfig, { | ||
+ return webpack_merge_1.default(baseConfig, { | ||
// Useless, disabled on purpose (errors on existing sites with no | ||
// browserslist config) | ||
// target: 'browserslist', | ||
@@ -35,13 +35,7 @@ async function createBaseClientConfig({ props, hydrate, minify, }) { | ||
plugins: [ | ||
new webpack_1.default.DefinePlugin({ | ||
'process.env.HYDRATE_CLIENT_ENTRY': JSON.stringify(hydrate), | ||
- }), | ||
- new ChunkAssetPlugin_1.default(), | ||
- // Show compilation progress bar and build time. | ||
- new webpackbar_1.default({ | ||
- name: 'Client', | ||
- }), | ||
- await (0, StaticDirectoriesCopyPlugin_1.createStaticDirectoriesCopyPlugin)({ props }), | ||
+ }) | ||
], | ||
}); | ||
} | ||
@@ -73,6 +67,7 @@ async function createStartClientConfig({ props, minify, poll, }) { | ||
preBodyTags, | ||
postBodyTags, | ||
}), | ||
+ | ||
], | ||
}); | ||
return { clientConfig }; | ||
diff --git a/lib/webpack/plugins/ChunkAssetPlugin.js b/lib/webpack/plugins/ChunkAssetPlugin.js | ||
index 4d896e310afb2fb4be10e703b2e734b0ea461cb3..940b924eb566591b6c9aad622e3c7f1d565f3383 100644 | ||
--- a/lib/webpack/plugins/ChunkAssetPlugin.js | ||
+++ b/lib/webpack/plugins/ChunkAssetPlugin.js | ||
@@ -22,6 +22,7 @@ const pluginName = 'chunk-asset-plugin'; | ||
*/ | ||
class ChunkAssetPlugin { | ||
apply(compiler) { | ||
+ return; | ||
compiler.hooks.thisCompilation.tap(pluginName, ({ mainTemplate }) => { | ||
mainTemplate.hooks.requireExtensions.tap(pluginName, (source, chunk) => { | ||
const chunkIdToName = chunk.getChunkMaps(false).name; | ||
diff --git a/lib/webpack/utils.js b/lib/webpack/utils.js | ||
index 76491bd66a3fe334cc2fe67dde5fc144b0db63d0..ef02d73eb67243e1d99a991ecdaa9b00ba6cae5c 100644 | ||
--- a/lib/webpack/utils.js | ||
+++ b/lib/webpack/utils.js | ||
@@ -54,7 +54,7 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) { | ||
] | ||
: [ | ||
{ | ||
- loader: mini_css_extract_plugin_1.default.loader, | ||
+ loader: require('webpack').CssExtractRspackPlugin.loader, | ||
options: { | ||
// Don't emit CSS files for SSR (previously used null-loader) | ||
// See https://github.com/webpack-contrib/mini-css-extract-plugin/issues/90#issuecomment-811991738 | ||
@@ -69,7 +69,7 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) { | ||
} | ||
return [ | ||
{ | ||
- loader: mini_css_extract_plugin_1.default.loader, | ||
+ loader: require('webpack').CssExtractRspackPlugin.loader, | ||
options: { | ||
esModule: true, | ||
}, |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.