mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-04 09:19:16 +02:00
feat(v2): Webpack 5, PostCSS 8 (#4089)
* Initial webpack 5 work * It works on my machine (lol) * Committing a bit more work * It works - sorta * Update packages/docusaurus/package.json * at least fix prettier /shrug * making more progress. build should work now, css stuff is still a bit broken * Terser things Signed-off-by: Reece Dunham <me@rdil.rocks> * Working on things * Vendor webpack * Repair chunks, and tests * Rerun prettier * Re-add client prefetching * Update snapshots * Update snapshots * I hope this works * Remove redundant dev server code * relock * Trying to reduce memory usage and fix things * Dead code elim * Search bar works!!! * Prefetching should work again * lock * ts issue * Repair snapshot * Run prettier * Fix the CI for now * fix lint-prettier * clean-css works, now for the other one * Fix lockfile * Fixes prettier * Other css minification works!!! * Add clean-css options, fix webpack versions Signed-off-by: Reece Dunham <me@rdil.rocks> * Fix tests and several of the webpack loaders Signed-off-by: Reece Dunham <me@rdil.rocks> * Re-add support for simple css minifier * Update other related dependencies * Fix lockfile * Dev server fixups Signed-off-by: Reece Dunham <me@rdil.rocks> * Simplify css things * Update webpack, try with postcss 7 * Other cssnano repairs * fix lockfile * Clean up the babel preset * Fix lockfile * Bump RL SSR version * Fix the build errors * Lockfile fix * It works again * webpack 5 should close compiler after run * add proper webpack5 persistent caching config * upgrade webpack deps again * reduce build perf timeouts to avoid build time regressions * test if incremental build can run on netlify * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * test * test * test * test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * netlify test * fix existsSync() calls * replace @ts-nocheck by a temporary Webpack type * replace @ts-nocheck by a temporary Webpack type * replace @ts-nocheck by a temporary Webpack type * migrate existing stats.warningsFilter to config.ignoreWarnings * remove stats from postBuild lifecycle data doc, as it is likely unused (we'll add it back if someone ask for it) * improve build.ts TS issues + move some sync code to async * cleanup TS of start.ts * fix TS error * fix TS issues * fix TS issues * fix ts error * netlify test * netlify test * netlify test * netlify test * netlify test * script cleanup * script cleanup * re-enable @typescript-eslint/ban-ts-comment * Deprecate getCacheLoader / getBabelLoader but keep retrocompatibility * useless TS * fix and comment gca(chunkName) prefetching function * remove deprecated mainTemplate.requireFn * temporarily use react-loadable-ssr-addon-v5-slorber until PR merged: https://github.com/facebook/docusaurus/pull/4089 * comment unsafeCache option * add explicit and more precise webpack targets * splitChunks, use new type: "css/mini-extract" as it seems recommended for webpack 5 * webpack error handling: - log error.details as documented - keep using react-dev-utils/formatWebpackMessages for now * fix webpack5 warnings for evalSourceMapMiddleware.js * typo * rename webpackHotDevClient * make all modifications of react-dev-utils explicit with a comment * revert LogPlugin adapter * loader-utils update * add useful share cache comment * add useful comments regarding the null-loader used in SSR for css files * upgrade webpack-merge in a retrocompatible way * use MiniCssExtractPlugin.emit false as recommended * use @docusaurus/responsive-loader * revert MiniCssExtractPlugin esModule: false change * add link to PR for custom CleanWebpackPlugin * pwa: add fallback to env variable or webpack 5 fails to build * upgrade to CssMinimizerPlugin 2.0 * only build en locale for windows tests * line breaks between errors * add useful comment * Fix e2e tests with Yarn2 not finding new init template dependencies * fix bad import * disable browserslist target as webpack already tries to use browserlists if a config is found, and it is a problem for existing sites * webpack5 TS fixes * fix getMinimizer order (even if it does not work yet) * update postcss to v8, fix cssnano minimizer errors * add NavbarItem position to types (useful for QuestDB site upgrade to Webpack5) * add webpack cache env variable to reduce risk of webpack 5 adoption Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
27b9f34635
commit
05e7250c08
63 changed files with 1790 additions and 1556 deletions
|
@ -398,7 +398,6 @@ type Props = {
|
|||
postBodyTags: string;
|
||||
routesPaths: string[];
|
||||
plugins: Plugin<any>[];
|
||||
stats: Stats.ToJsonOutput;
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -408,13 +407,11 @@ Example:
|
|||
module.exports = function (context, options) {
|
||||
return {
|
||||
name: 'docusaurus-plugin',
|
||||
async postBuild({siteConfig = {}, routesPaths = [], outDir, stats}) {
|
||||
async postBuild({siteConfig = {}, routesPaths = [], outDir}) {
|
||||
// Print out to console all the rendered routes.
|
||||
routesPaths.map((route) => {
|
||||
console.log(route);
|
||||
});
|
||||
// Print out to console all the webpack stats.
|
||||
console.log(stats);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
|
||||
# Note: this file's config override the Netlify UI admin config
|
||||
# Note: this file's config overrides the Netlify UI admin config
|
||||
|
||||
# /!\ due to using a monorepo it can be a bit messy to configure Netlify
|
||||
# See also https://github.com/netlify/build/issues/2483
|
||||
|
||||
# default/production build
|
||||
[build]
|
||||
base = "/"
|
||||
command = "yarn workspace docusaurus-2-website netlify:build:production"
|
||||
command = "yarn --cwd .. build:packages && yarn build"
|
||||
publish = "website/build"
|
||||
|
||||
# we build deploy previews with a /build/ baseUrl on purpose
|
||||
# permits to test that baseUrl works fine (this often breaks!)
|
||||
[build.environment]
|
||||
NETLIFY_USE_YARN = "true"
|
||||
YARN_VERSION = "1.22.5"
|
||||
NODE_VERSION = "14"
|
||||
|
||||
[context.production]
|
||||
command = "yarn --cwd .. build:packages && yarn netlify:build:production"
|
||||
|
||||
[context.deploy-preview]
|
||||
command = "yarn workspace docusaurus-2-website netlify:build:deployPreview"
|
||||
publish = "website/build"
|
||||
command = "yarn --cwd .. build:packages && yarn netlify:build:deployPreview"
|
||||
|
||||
[[plugins]]
|
||||
package = "netlify-plugin-cache"
|
||||
[plugins.inputs]
|
||||
paths = [
|
||||
"node_modules/.cache/webpack",
|
||||
]
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
"@docusaurus/theme-live-codeblock": "2.0.0-alpha.74",
|
||||
"clsx": "^1.1.1",
|
||||
"color": "^3.1.3",
|
||||
"netlify-plugin-cache": "^1.0.3",
|
||||
"npm-to-yarn": "^1.0.0-2",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue