Skip to main content

deploySite()

获取一个 Remotion 项目,对其进行打包并上传到 S3 存储桶。一旦上传,Lambda 函数可以通过指定 URL 来渲染 Remotion 项目中的任何组合。

🌐 Takes a Remotion project, bundles it and uploads it to an S3 bucket. Once uploaded, a Lambda function can render any composition in the Remotion project by specifying the URL.

  • 如果你在本地进行更改,需要重新部署网站。你可以使用 siteName 来覆盖之前的网站。
  • 请注意,Remotion 项目将部署到子目录,而不是域的根目录。因此,你必须确保如果在 Remotion 项目中指定了路径,它们能够处理这种情况。
  • 在调用此函数之前,你应该创建一个存储桶,请参阅 getOrCreateBucket()

示例

🌐 Example

import {deploySite} from '@remotion/lambda';
import path from 'path';

const {serveUrl} = await deploySite({
  entryPoint: path.resolve(process.cwd(), 'src/index.ts'),
  bucketName: 'remotionlambda-c7fsl3d',
  region: 'us-east-1',
  options: {
    onBundleProgress: (progress) => {
      // Progress is between 0 and 100
      console.log(`Bundle progress: ${progress}%`);
    },
    onUploadProgress: ({totalFiles, filesUploaded, totalSize, sizeUploaded}) => {
      console.log(`Upload progress: Total files ${totalFiles}, Files uploaded ${filesUploaded}, Total size ${totalSize}, Size uploaded ${sizeUploaded}`);
    },
  },
});
console.log(serveUrl);

参数

🌐 Arguments

一个具有以下属性的对象:

🌐 An object with the following properties:

entryPoint

指向你的 Remotion 项目入口点的绝对路径。通常你的 Remotion 项目的入口点存储在 src/entry.tsx

🌐 An absolute path pointing to the entry point of your Remotion project. Usually the entry point in your Remotion project is stored at src/entry.tsx.

bucketName

网站将被部署到的存储桶。该存储桶必须由 Remotion Lambda 创建。

🌐 The bucket to where the website will be deployed. The bucket must have been created by Remotion Lambda.

region

存储桶所在的 AWS 区域。

🌐 The AWS region in which the bucket resides.

siteName?

指定你希望网站部署到的 S3 存储桶子文件夹。如果省略此属性,将创建一个随机名称的新子文件夹。如果已存在与你传递的名称相同的网站,它将被覆盖。只能包含以下字符:0-9a-zA-Z-!_.*'()

🌐 Specify the subfolder in your S3 bucket that you want the site to deploy to. If you omit this property, a new subfolder with a random name will be created. If a site already exists with the name you passed, it will be overwritten. Can only contain the following characters: 0-9, a-z, A-Z, -, !, _, ., *, ', (, )

logLevel?v4.0.140

One of trace, verbose, info, warn, error.
Determines how much info is being logged to the console.

Default info.

options?

一个具有以下属性的对象:

🌐 An object with the following properties:

onBundleProgress?

当打包进度有更新时,Webpack 的回调函数会被触发。回调函数会接收一个介于 0 到 100 之间的数字,具体示例见页面顶部。

🌐 Callback from Webpack when the bundling has progressed. Passes a number between 0 and 100 to the callback, see example at the top of the page.

onUploadProgress?

当资源上传进度更新时调用的回调函数。将包含以下属性的对象传递给回调函数:

🌐 Callback function that gets called when uploading of the assets has progressed. Passes an object with the following properties to the callback:

  • totalFiles (数字):包中的文件总数。
  • filesUploaded数字):到目前为止已完全上传的文件数量。
  • totalSize (数字): 打包包中所有文件的总大小(字节)。
  • sizeUploaded (number):到目前为止上传的字节数。

webpackOverride?

允许传递自定义的 webpack 覆盖。更多信息请参见 bundle() -> webpackOverride

🌐 Allows to pass a custom webpack override. See bundle() -> webpackOverride for more information.

enableCaching?

Enable or disable Webpack caching. This flag is enabled by default, use --bundle-cache=false to disable caching.

publicDir?

从 v3.2.17 起可用

🌐 available from v3.2.17

Define the location of the public/ directory. If not defined, Remotion will assume the location is the `public` folder in your Remotion root.

rootDir?

从 v3.2.17 起可用

🌐 available from v3.2.17

Remotion 项目所在的根目录。此目录应设置为包含安装 Remotion 的 package.json 的目录。默认情况下,它是当前工作目录。

🌐 The directory in which the Remotion project is rooted in. This should be set to the directory that contains the package.json which installs Remotion. By default, it is the current working directory.

note

当前工作目录是程序执行时所在的目录。它与调用 bundle() 的文件所在的目录不同。

ignoreRegisterRootWarning?

从 v3.3.55 起可用

🌐 available from v3.3.55

如果传入的入口文件不包含 registerRoot,则忽略抛出的错误。

🌐 Ignore an error that gets thrown if you pass an entry point file which does not contain registerRoot.

keyboardShortcutsEnabled?v4.0.407

Enable or disable keyboard shortcuts in the Remotion Studio.

askAIEnabled?v4.0.407

If the Cmd + I shortcut of the Ask AI modal conflicts with your Studio, you can disable it using this.

experimentalClientSideRenderingEnabled?v4.0.407

Enable WIP client-side rendering in the Remotion Studio. See https://www.remotion.dev/docs/client-side-rendering/ for notes.

rspack?v4.0.426

Uses Rspack instead of Webpack as the bundler for the Studio or bundle.

privacy?

从 v3.3.97 起可用

🌐 available from v3.3.97

如果不使用ACL,可以选择 public(默认)或 no-acl。站点必须具有公共URL,才能在Lambda上呈现,因为无头浏览器会打开该URL。

🌐 Either public (default) or no-acl if you are not using ACL. Sites must have a public URL to be able to be rendered on Lambda, since the headless browser opens that URL.

throwIfSiteExists?v4.0.141

Prevents accidential update of an existing site. If there are any files in the subfolder where the site should be placed, the function will throw.

forcePathStyle?v4.0.202

forcePathStyle 传递给 AWS S3 客户端。如果你不知道这是什么,你很可能用不到它。

🌐 Passes forcePathStyle to the AWS S3 client. If you don't know what this is, you probably don't need it.

返回值

🌐 Return value

一个具有以下值的对象:

🌐 An object with the following values:

  • serveUrl (字符串): 一个像 https://remotionlambda-12345.s3.eu-central-1.amazonaws.com/sites/abcdef/index.html 这样的 URL。

    你可以使用此“Serve URL”在 Remotion Lambda 上渲染视频,方法如下:

    如果你在 Lambda 上进行渲染,你也可以将站点名称(在这种情况下为 abcdef)作为缩写传递。

  • siteName (字符串): 提供的网站标识符。它要么是你传入此函数的站点名称,要么是在你未传入站点名称时生成的随机字符串。

  • stats:(从 v3.3.7 起可用) 一个包含 3 个条目的对象:uploadedFilesdeletedFilesuntouchedFiles。每个都是一个 number

更新日志

🌐 Changelog

v3.3.7 开始,这个函数是增量的:它只比较本地文件和 S3 上文件的内容,并且只执行必要的操作。

🌐 From v3.3.7, this function is incremental: It only compares the contents of the local files and the files on S3 and only executes the necessary operations.

另请参阅

🌐 See also