🎥 Make videos programmatically with React
Docs: How to enable SVGR
Jonny Burgerb403663153e1
diff --git a/packages/docs/components/Installation.tsx b/packages/docs/components/Installation.tsxindex 6be048a509..fa979442cd 100644--- a/packages/docs/components/Installation.tsx+++ b/packages/docs/components/Installation.tsx@@ -8,7 +8,7 @@ import Tabs from "@theme/Tabs";import { VERSION } from "remotion";const LightAndDark: React.FC<{- text: string;+ readonly text: string;}> = ({ text }) => {return (<>@@ -41,7 +41,7 @@ const LightAndDark: React.FC<{};export const Installation: React.FC<{- pkg: string;+ readonly pkg: string;}> = ({ pkg }) => {if (pkg === undefined) {throw new Error("pkg is undefined");@@ -58,6 +58,8 @@ export const Installation: React.FC<{}).join(" ");+ const isRemotionPackage = packages.includes("remotion");+return (<div><Tabs@@ -82,13 +84,17 @@ export const Installation: React.FC<{<LightAndDark text={`yarn --exact add ${packages}`} /></TabItem></Tabs>- This assumes you are currently using v{VERSION} of Remotion.- <br />- Also update <code>remotion</code> and all <code>`@remotion/*`</code>{" "}- packages to the same version.- <br />- Remove all <code>^</code> character in front of the version numbers of it- as it can lead to a version conflict.+ {isRemotionPackage ? (+ <>+ This assumes you are currently using v{VERSION} of Remotion.+ <br />+ Also update <code>remotion</code> and all <code>`@remotion/*`</code>{" "}+ packages to the same version.+ <br />+ Remove all <code>^</code> character in front of the version numbers of+ it as it can lead to a version conflict.+ </>+ ) : null}</div>);};diff --git a/packages/docs/docs/overwriting-webpack-config.mdx b/packages/docs/docs/overwriting-webpack-config.mdxindex 0f81d99b79..8c7ea047cd 100644--- a/packages/docs/docs/overwriting-webpack-config.mdx+++ b/packages/docs/docs/overwriting-webpack-config.mdx@@ -111,37 +111,7 @@ await deploySite({1. Install the following dependencies:-<Tabs-defaultValue="npm"-values={[-{ label: 'npm', value: 'npm', },-{ label: 'yarn', value: 'yarn', },-{ label: 'pnpm', value: 'pnpm', },-]-}>-<TabItem value="npm">--```bash-npm i @mdx-js/loader @mdx-js/react-```-- </TabItem>- <TabItem value="pnpm">--```bash-pnpm i @mdx-js/loader @mdx-js/react-```-- </TabItem>-- <TabItem value="yarn">--```bash-yarn add @mdx-js/loader @mdx-js/react-```-- </TabItem>-</Tabs>+<Installation pkg="@mdx-js/loader @mdx-js/react" />2. Create a file with the Webpack override:@@ -199,37 +169,7 @@ Config.overrideWebpackConfig(enableMdx);1. Install the following dependencies:-<Tabs-defaultValue="npm"-values={[-{ label: 'npm', value: 'npm', },-{ label: 'yarn', value: 'yarn', },-{ label: 'pnpm', value: 'pnpm', },-]-}>-<TabItem value="npm">--```bash-npm i sass style-loader css-loader sass-loader-```-- </TabItem>- <TabItem value="pnpm">--```bash-pnpm i sass style-loader css-loader sass-loader-```-- </TabItem>-- <TabItem value="yarn">--```bash-yarn add sass style-loader css-loader sass-loader-```-- </TabItem>-</Tabs>+<Installation pkg="sass style-loader css-loader sass-loader" />2. Declare an override function:@@ -277,41 +217,63 @@ Config.overrideWebpackConfig(enableSass);5. Restart the Remotion Studio.-### Enable support for GLSL imports+### Enable SVGR support-1. Install the following dependencies:+This allows you to enable `import` SVG files as React components.-<Tabs-defaultValue="npm"-values={[-{ label: 'npm', value: 'npm', },-{ label: 'yarn', value: 'yarn', },-{ label: 'pnpm', value: 'pnpm', },-]-}>-<TabItem value="npm">+1. Install the following dependency:-```bash-npm i glsl-shader-loader glslify glslify-import-loader raw-loader-```+<Installation pkg="@svgr/webpack" />- </TabItem>+2. Declare an override function:- <TabItem value="yarn">+```ts twoslash title="src/enable-svgr.ts"+import { WebpackOverrideFn } from "@remotion/bundler";-```bash-yarn add glsl-shader-loader glslify glslify-import-loader raw-loader+export const enableSvgr: WebpackOverrideFn = (currentConfiguration) => {+ return {+ ...currentConfiguration,+ module: {+ ...currentConfiguration.module,+ rules: [+ {+ test: /\.svg$/i,+ issuer: /\.[jt]sx?$/,+ resourceQuery: { not: [/url/] }, // Exclude react component if *.svg?url+ use: ["@svgr/webpack"],+ },+ ...(currentConfiguration.module?.rules+ ? currentConfiguration.module.rules+ : []),+ ],+ },+ };+};```- </TabItem>- <TabItem value="pnpm">+3. Add the override function to your [`remotion.config.ts`](/docs/config) file:-```bash-pnpm i glsl-shader-loader glslify glslify-import-loader raw-loader+```ts twoslash title="remotion.config.ts"+// @filename: ./src/enable-svgr.ts+import { WebpackOverrideFn } from "@remotion/bundler";+export const enableSvgr: WebpackOverrideFn = (c) => c;+// @filename: remotion.config.ts+// ---cut---+import { Config } from "@remotion/cli/config";+import { enableSvgr } from "./src/enable-svgr";++Config.overrideWebpackConfig(enableSvgr);```- </TabItem>-</Tabs>+4. Add it to your [Node.JS API calls as well if necessary](#when-using-bundle-and-deploysite).++5. Restart the Remotion Studio.++### Enable support for GLSL imports++1. Install the following dependencies:++<Installation pkg="glsl-shader-loader glslify glslify-import-loader raw-loader" />2. Declare a webpack override: