Skip to content

🎥 Make videos programmatically with React

link webpack config in ts aliases

Jonny Burgerc027090626dc
diff --git a/packages/docs/docs/miscellaneous/ts-aliases.mdx b/packages/docs/docs/miscellaneous/ts-aliases.mdx
index 49142b0b76..8908c0e008 100644
--- a/packages/docs/docs/miscellaneous/ts-aliases.mdx
+++ b/packages/docs/docs/miscellaneous/ts-aliases.mdx
@@ -1,13 +1,13 @@
---
image: /generated/articles-docs-miscellaneous-ts-aliases.png
-title: "TypeScript aliases"
+title: 'TypeScript aliases'
id: typescript-aliases
slug: /typescript-aliases
-crumb: "How to"
+crumb: 'How to'
---
Typescript aliases are not supported by default, since the ESBuild Webpack loader we have does not support them.
-You can however patch the Webpack config to make them resolve.
+You can however patch the [Webpack config](/docs/webpack) to make them resolve.
Assuming you have a file:
@@ -35,8 +35,8 @@ and your tsconfig.json has the following `paths`:
you can add the aliases to Webpack, however you need to add each of them manually:
```ts twoslash
-import path from "path";
-import { Config } from "@remotion/cli/config";
+import path from 'path';
+import {Config} from '@remotion/cli/config';
Config.overrideWebpackConfig((config) => {
return {
@@ -45,7 +45,7 @@ Config.overrideWebpackConfig((config) => {
...config.resolve,
alias: {
...(config.resolve?.alias ?? {}),
- lib: path.join(process.cwd(), "src", "lib"),
+ lib: path.join(process.cwd(), 'src', 'lib'),
},
},
};
@@ -59,18 +59,15 @@ Remember that in Node.JS APIs, the config file does not apply, so you need to ad
To not duplicate the aliases in your Webpack override and in your `tsconfig.json`, you can install `tsconfig-paths-webpack-plugin` and use it:
```ts
-import { Config } from "@remotion/cli/config";
-import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
+import {Config} from '@remotion/cli/config';
+import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
Config.overrideWebpackConfig((config) => {
return {
...config,
resolve: {
...config.resolve,
- plugins: [
- ...(config.resolve?.plugins ?? []),
- new TsconfigPathsPlugin(),
- ],
+ plugins: [...(config.resolve?.plugins ?? []), new TsconfigPathsPlugin()],
},
};
});