Skip to content

🎥 Make videos programmatically with React

example for TS aliases

Jonny Burgerb5274ea73de4
diff --git a/packages/example/remotion.config.ts b/packages/example/remotion.config.ts
index d894bf8eed..bdc7a6221f 100644
--- a/packages/example/remotion.config.ts
+++ b/packages/example/remotion.config.ts
@@ -1,5 +1,21 @@
+import path from 'path';
import {Config} from 'remotion';
import {webpackOverride} from './webpack-override';
Config.Output.setOverwriteOutput(true);
Config.Bundling.overrideWebpackConfig(webpackOverride);
+Config.Bundling.overrideWebpackConfig((config) => {
+ const newConfig = webpackOverride(config);
+ return {
+ ...newConfig,
+ resolve: {
+ ...newConfig.resolve,
+ alias: {
+ ...newConfig.resolve.alias,
+ 'lib/alias': require.resolve(
+ path.join(process.cwd(), 'src', 'lib', 'alias.ts')
+ ),
+ },
+ },
+ };
+});
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index 45cbbc3162..f4628f3717 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -1,3 +1,4 @@
+import {alias} from 'lib/alias';
import React from 'react';
import {Composition, Folder, getInputProps, Still} from 'remotion';
import {TwentyTwoKHzAudio} from './22KhzAudio';
@@ -25,6 +26,10 @@ import {Greenscreen} from './VideoOnCanvas/greenscreen';
import {VideoSpeed} from './VideoSpeed';
import {VideoTesting} from './VideoTesting';
+if (alias !== 'alias') {
+ throw new Error('should support TS aliases');
+}
+
// Use it to test that UI does not regress on weird CSS
// import './weird-css.css';
diff --git a/packages/example/src/lib/alias.ts b/packages/example/src/lib/alias.ts
new file mode 100644
index 0000000000..d4cbb03d9d
--- /dev/null
+++ b/packages/example/src/lib/alias.ts
@@ -0,0 +1 @@
+export const alias = 'alias';
diff --git a/packages/example/tsconfig.json b/packages/example/tsconfig.json
index 151e5ac2a1..794e9bdf6e 100644
--- a/packages/example/tsconfig.json
+++ b/packages/example/tsconfig.json
@@ -5,7 +5,10 @@
"outDir": "./dist",
"jsx": "react-jsx",
"skipLibCheck": true,
- "allowSyntheticDefaultImports": true
+ "allowSyntheticDefaultImports": true,
+ "paths": {
+ "lib/*": ["./src/lib/*"]
+ }
},
"include": ["src"],
"references": [