From a5fd530ffcf1690b8ed4740c55d0184ba9eb2232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Sun, 22 Sep 2024 13:59:33 +0200 Subject: [PATCH] fix: remove babel.config.js from init templates + website (#10514) --- .../templates/classic-typescript/package.json | 1 - .../create-docusaurus/templates/classic/package.json | 1 - .../templates/shared/babel.config.js | 3 --- website/babel.config.js | 10 ---------- website/docs/configuration.mdx | 12 ++++++++++-- 5 files changed, 10 insertions(+), 17 deletions(-) delete mode 100644 packages/create-docusaurus/templates/shared/babel.config.js delete mode 100644 website/babel.config.js diff --git a/packages/create-docusaurus/templates/classic-typescript/package.json b/packages/create-docusaurus/templates/classic-typescript/package.json index 88f1117814f7..56bba3947c42 100644 --- a/packages/create-docusaurus/templates/classic-typescript/package.json +++ b/packages/create-docusaurus/templates/classic-typescript/package.json @@ -15,7 +15,6 @@ "typecheck": "tsc" }, "dependencies": { - "@docusaurus/babel": "3.5.2", "@docusaurus/core": "3.5.2", "@docusaurus/preset-classic": "3.5.2", "@mdx-js/react": "^3.0.0", diff --git a/packages/create-docusaurus/templates/classic/package.json b/packages/create-docusaurus/templates/classic/package.json index c0dad98a022c..2d2535698e05 100644 --- a/packages/create-docusaurus/templates/classic/package.json +++ b/packages/create-docusaurus/templates/classic/package.json @@ -14,7 +14,6 @@ "write-heading-ids": "docusaurus write-heading-ids" }, "dependencies": { - "@docusaurus/babel": "3.5.2", "@docusaurus/core": "3.5.2", "@docusaurus/preset-classic": "3.5.2", "@mdx-js/react": "^3.0.0", diff --git a/packages/create-docusaurus/templates/shared/babel.config.js b/packages/create-docusaurus/templates/shared/babel.config.js deleted file mode 100644 index ca4e55cbf11f..000000000000 --- a/packages/create-docusaurus/templates/shared/babel.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - presets: ['@docusaurus/babel/preset'], -}; diff --git a/website/babel.config.js b/website/babel.config.js deleted file mode 100644 index 25875e982f12..000000000000 --- a/website/babel.config.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -module.exports = { - presets: ['@docusaurus/babel/preset'], -}; diff --git a/website/docs/configuration.mdx b/website/docs/configuration.mdx index 8278b5cc3fe9..8415e71cf5cb 100644 --- a/website/docs/configuration.mdx +++ b/website/docs/configuration.mdx @@ -275,7 +275,15 @@ If you just want to use those fields on the client side, you could create your o ## Customizing Babel Configuration {#customizing-babel-configuration} -For new Docusaurus projects, we automatically generated a `babel.config.js` in the project root. +Docusaurus transpiles your site's source code using Babel by default. If you want to customize the Babel configuration, you can do so by creating a `babel.config.js` file in your project root. + +To use the built-in preset as a base configuration, install the following package and use it + +```bash npm2yarn +npm install --save @docusaurus/theme-live-codeblock +``` + +Then use the preset in your `babel.config.js` file: ```js title="babel.config.js" export default { @@ -283,4 +291,4 @@ export default { }; ``` -Most of the time, this configuration will work just fine. If you want to customize your Babel configuration (e.g. to add support for Flow), you can directly edit this file. For your changes to take effect, you need to restart the Docusaurus dev server. +Most of the time, the default preset configuration will work just fine. If you want to customize your Babel configuration (e.g. to add support for Flow), you can directly edit this file. For your changes to take effect, you need to restart the Docusaurus dev server.