Skip to content

🎥 Make videos programmatically with React

add docs for babel loader

Jonny Burger50371a5ced13
diff --git a/packages/docs/docs/legacy-babel-loader.md b/packages/docs/docs/legacy-babel-loader.md
new file mode 100644
index 0000000000..6438849a99
--- /dev/null
+++ b/packages/docs/docs/legacy-babel-loader.md
@@ -0,0 +1,38 @@
+---
+title: Using legacy Babel transpilation
+id: legacy-babel
+---
+
+:::warning
+This component is part of Remotion 2.0 which is not yet released. The information on this page might not yet accurately reflect the current state of Remotions API.
+:::warning
+
+In Remotion 2.0, the traditional transpilation of Javascript and Typescript using the `babel-loader` has been replaced by the faster `esbuild-loader` by default.
+
+If you for some reason need to go back to the previous behavior, you may [override the Webpack configuration](webpack). Remember that overriding the Webpack configuration works reducer-style, where you get the default configuration in a function argument and you return the modified version of your config.
+
+We provide a compatibility package `@remotion/babel-loader` that you can install into your Remotion project and use the function `replaceLoadersWithBabel()` to swap out the ESBuild loader with the old Babel one that was in Remotion 1.0
+
+This should not be necessary in general, it is encouraged to [report issues](https://github.com/JonnyBurger/remotion/issues/new) regarding the new ESBuild loader.
+
+## Example
+
+console
+
+```
+npm i @remotion/babel-loader
+```
+
+`remotion.config.ts`
+
+```tsx
+import {replaceLoadersWithBabel} from '@remotion/babel-loader';
+
+Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
+ return replaceLoadersWithBabel(currentConfiguration);
+});
+```
+
+## See also
+
+- [Custom Webpack config](webpack)
diff --git a/packages/docs/docs/overwriting-webpack-config.md b/packages/docs/docs/overwriting-webpack-config.md
index e1733b924f..fb6301214b 100644
--- a/packages/docs/docs/overwriting-webpack-config.md
+++ b/packages/docs/docs/overwriting-webpack-config.md
@@ -36,50 +36,98 @@ Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
Using the reducer pattern will help with type safety, give you auto-complete, ensure forwards-compatibility and keep it completely flexible - you can override just one property or pass in a completely new Webpack configuration.
:::
-## Enabling MDX support
+## Snippets
+
+### Enabling MDX support
The following `remotion.config.ts` file shows how to enable support for MDX. Installation of `mdx-loader babel-loader @babel/preset-env @babel/preset-react` is required.
```ts
-import {overrideWebpackConfig} from '@remotion/bundler';
-
-overrideWebpackConfig((currentConfiguration) => {
- return {
- ...currentConfiguration,
- module: {
- ...currentConfiguration.module,
- rules: [
- ...currentConfiguration.module.rules,
- {
- test: /\.mdx?$/,
- use: [
- {
- loader: 'babel-loader',
- options: {
- presets: [
- '@babel/preset-env',
- [
- '@babel/preset-react',
- {
- runtime: 'automatic',
- },
- ],
- ],
- },
- },
- 'mdx-loader',
- ],
- },
- ],
- },
- };
+Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
+ return {
+ ...currentConfiguration,
+ module: {
+ ...currentConfiguration.module,
+ rules: [
+ ...(currentConfiguration.module?.rules
+ ? currentConfiguration.module.rules
+ : []),
+ {
+ test: /\.mdx?$/,
+ use: [
+ {
+ loader: 'babel-loader',
+ options: {
+ presets: [
+ '@babel/preset-env',
+ [
+ '@babel/preset-react',
+ {
+ runtime: 'automatic',
+ },
+ ],
+ ],
+ },
+ },
+ 'mdx-loader',
+ ],
+ },
+ ],
+ },
+ };
});
+
```
:::info
Create a file which contains `declare module '*.mdx';` in your project to fix a TypeScript error showing up.
:::
+### Enable SASS/SCSS support
+
+```tsx
+import {Config} from 'remotion';
+
+Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
+ return {
+ ...currentConfiguration,
+ module: {
+ ...currentConfiguration.module,
+ rules: [
+ ...(currentConfiguration.module?.rules
+ ? currentConfiguration.module.rules
+ : []),
+ // Add more loaders here
+ {
+ // look for .css or .scss files
+ test: /\.(css|scss)$/,
+ // in the `src` directory
+ include: [resolveApp('src')],
+ use: [
+ {
+ loader: 'style-loader',
+ },
+ {
+ loader: 'css-loader',
+ },
+ {
+ loader: 'sass-loader',
+ options: {
+ sourceMap: true,
+ },
+ },
+ ],
+ },
+ ],
+ },
+ };
+});
+```
+
+### Use legacy babel loader
+
+See [Using legacy Babel transpilation](legacy-babel).
+
## Customizing configuration file location
You can pass a `--config` option to the command line to specify a custom location for your configuration file.
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index bec5e765be..0d99dfca29 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -27,6 +27,7 @@ module.exports = {
"encoding",
"transparent-videos",
"dynamic-metadata",
+ "legacy-babel",
],
},
{