🎥 Make videos programmatically with React
Docs: Add Webpack config mutation example (#8773)
Jonny Burger3aa0e9852e7c
diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdxindex a71147e861..1f297a6f88 100644--- a/packages/docs/docs/config.mdx+++ b/packages/docs/docs/config.mdx@@ -31,7 +31,7 @@ Allows you to insert your custom Webpack config. [See the page about custom Webpimport {Config} from '@remotion/cli/config';// ---cut---Config.overrideWebpackConfig((currentConfiguration) => {- // Return a new Webpack configuration+ // Return a new Webpack configuration or mutate this one and return itreturn {...currentConfiguration,// new configurationdiff --git a/packages/docs/docs/overwriting-webpack-config.mdx b/packages/docs/docs/overwriting-webpack-config.mdxindex 57d561c530..0a092615a6 100644--- a/packages/docs/docs/overwriting-webpack-config.mdx+++ b/packages/docs/docs/overwriting-webpack-config.mdx@@ -8,9 +8,9 @@ crumb: 'How To'import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';-Remotion ships with [it's own Webpack configuration](https://github.com/remotion-dev/remotion/blob/main/packages/bundler/src/webpack-config.ts).+Remotion ships with [its own Webpack configuration](https://github.com/remotion-dev/remotion/blob/main/packages/bundler/src/webpack-config.ts).-You can override it reducer-style by creating a function that takes the previous Webpack configuration and returns the the new one.+You can override it reducer-style by creating a function that takes the previous Webpack configuration and returns the next one.## When rendering using the command line@@ -33,6 +33,24 @@ Config.overrideWebpackConfig((currentConfiguration) => {});```+You may also mutate the configuration object. Return the same object after mutating it:++```ts twoslash title="remotion.config.ts"+import {Config} from '@remotion/cli/config';++Config.overrideWebpackConfig((config) => {+ config.module ??= {};+ config.module.rules ??= [];++ config.module.rules.push({+ test: /\.txt$/,+ type: 'asset/source',+ });++ return config;+});+```+:::infoUsing 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.:::