setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrepare a Remotion project for remocn
为 remocn 准备 Remotion 项目
Project root: $ARGUMENTS (the current folder when empty)
shadcn init项目根目录:$ARGUMENTS(为空时为当前文件夹)
shadcn init0. Check the project
0. 检查项目
Read in the project root.
package.json- No : stop and say so.
package.json - No in
remotionordependencies: it isn't a Remotion project. Stop and say so. ThedevDependenciesskill creates one withvideo.npx create-video@latest --yes --blank <folder>
In a project the user already had, list the files from the steps below that you will touch and ask
before editing them.
读取项目根目录中的 。
package.json- 不存在 :停止操作并告知用户。
package.json - 或
dependencies中没有devDependencies:这不是 Remotion 项目。停止操作并告知用户。remotionskill 可以使用video创建一个项目。npx create-video@latest --yes --blank <folder>
对于用户原本已有的项目,请列出后续步骤中将要修改的文件,并在编辑前征得用户同意。
1. components.json
components.json1. components.json
components.json-
Missing: create it with exactly this content:json
{ "$schema": "https://ui.shadcn.com/schema.json", "style": "new-york", "rsc": false, "tsx": true, "tailwind": { "config": "", "css": "", "baseColor": "neutral", "cssVariables": false }, "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" }, "registries": { "@remocn": "https://remocn.dev/r/{name}.json" } } -
Present, no: add
registries["@remocn"]to"@remocn": "https://remocn.dev/r/{name}.json", creating the object if needed. Leave every other field as it is.registries -
Already has: leave it.
@remocn
-
不存在: 使用以下完全相同的内容创建它:json
{ "$schema": "https://ui.shadcn.com/schema.json", "style": "new-york", "rsc": false, "tsx": true, "tailwind": { "config": "", "css": "", "baseColor": "neutral", "cssVariables": false }, "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" }, "registries": { "@remocn": "https://remocn.dev/r/{name}.json" } } -
已存在,但不存在: 将
registries["@remocn"]添加到"@remocn": "https://remocn.dev/r/{name}.json",必要时创建该对象。其他所有字段保持不变。registries -
已经包含: 保持不变。
@remocn
2. The @/*
path in tsconfig.json
@/*tsconfig.json2. tsconfig.json
中的 @/*
path
tsconfig.json@/*remocn components import each other through , so TypeScript has to resolve it.
may hold comments and trailing commas: edit it in place and keep them.
@/tsconfig.jsonWork out the alias folder, the folder points at, relative to the project root. You need it
in step 3.
@/- exists: leave the file. The alias folder is its first entry without the trailing
compilerOptions.paths["@/*"](/*→./src/*), resolved againstsrcwhen one is set, else against the folder ofcompilerOptions.baseUrl.tsconfig.json - The file has and no
extendsof its own: a localpathswould replace the inherited map, not merge with it. Open the config it extends (one level, relative paths only). If that one haspaths, leave both files and take the alias folder from there, resolved against the parent's folder. If it doesn't, don't edit: tell the user to add@/*where their paths are defined, and use"@/*": ["./src/*"]as the alias folder.src - Otherwise: add to
"@/*": ["./src/*"], creatingcompilerOptions.pathsif needed and keeping existing entries. With apathsother thanbaseUrl, write the path to.relative to thesrcinstead. The alias folder isbaseUrl.src - No : don't create one. The alias folder is
tsconfig.json.src
remocn 组件通过 相互 import,因此 TypeScript 必须能够解析它。 中可能包含注释和尾随逗号:请原地编辑并保留它们。
@/tsconfig.json确定 alias 文件夹,即相对于项目根目录、 指向的文件夹。步骤 3 需要使用它。
@/- 已存在: 保持文件不变。alias 文件夹是其第一个条目去掉末尾
compilerOptions.paths["@/*"]后的结果(/*→./src/*);如果设置了src,则相对于该compilerOptions.baseUrl解析,否则相对于baseUrl所在文件夹解析。tsconfig.json - 文件包含 ,但没有自己的
extends: 本地paths会替换继承的映射,而不是与其合并。打开它继承的配置(仅处理一层,且仅限相对路径)。如果该配置包含paths,则两个文件都保持不变,并从其中获取 alias 文件夹,相对于父配置的文件夹解析。如果没有,则不要编辑:告知用户,应在其定义 paths 的位置添加@/*,并将"@/*": ["./src/*"]作为 alias 文件夹。src - 其他情况: 将 添加到
"@/*": ["./src/*"],必要时创建compilerOptions.paths,并保留现有条目。如果paths不是baseUrl,则写入相对于.指向baseUrl的路径。alias 文件夹为src。src - 不存在 : 不要创建。alias 文件夹为
tsconfig.json。src
3. The @
alias in remotion.config.ts
@remotion.config.ts3. remotion.config.ts
中的 @
alias
remotion.config.ts@The bundler needs the same alias. Look for , then , in the
project root. If the file already contains , leave it.
remotion.config.tsremotion.config.jswithRemocnAliasThe alias target is , or when the alias
folder is the project root itself.
path.join(process.cwd(), "<alias folder>")process.cwd()- No config file: create with the imports and the block below.
remotion.config.ts - exists: add
remotion.config.tsandimport path from "node:path";at the top unless they're already imported, then append the block at the end of the file.import { Config } from "@remotion/cli/config"; - exists: append the same block without the type annotations (
remotion.config.jsandconst withRemocnAlias = (config) => ({ ... })), and the same two imports if missing.config.resolve?.alias ?? {}
ts
// remocn components import each other through the "@/" alias in components.json.
// Bundlers don't read tsconfig paths, so the alias is resolved here as well.
// Both overrides are deliberate: the Remotion CLI applies overrideBundlerConfig
// with webpack and rspack alike, while Remocn Studio's preview reads only
// overrideWebpackConfig. Both run from the project root, which process.cwd()
// points at.
const withRemocnAlias = <C extends { resolve?: object }>(config: C): C => ({
...config,
resolve: {
...config.resolve,
alias: {
...((config.resolve as { alias?: object } | undefined)?.alias ?? {}),
"@": path.join(process.cwd(), "src"),
},
},
});
// overrideBundlerConfig only exists in newer Remotion 4 releases.
if (typeof Config.overrideBundlerConfig === "function") {
Config.overrideBundlerConfig(withRemocnAlias);
}
Config.overrideWebpackConfig(withRemocnAlias);Replace with the alias target from above when they differ.
path.join(process.cwd(), "src")bundler 需要相同的 alias。在项目根目录中先查找 ,然后查找 。如果文件已经包含 ,则保持不变。
remotion.config.tsremotion.config.jswithRemocnAliasalias 目标为 ;如果 alias 文件夹就是项目根目录,则目标为 。
path.join(process.cwd(), "<alias folder>")process.cwd()- 不存在配置文件: 使用以下 imports 和代码块创建 。
remotion.config.ts - 已存在: 除非已经 import,否则在文件顶部添加
remotion.config.ts和import path from "node:path";,然后将代码块追加到文件末尾。import { Config } from "@remotion/cli/config"; - 已存在: 追加相同的代码块,但不带类型标注(
remotion.config.js和const withRemocnAlias = (config) => ({ ... })),并在缺少时添加上述两个 imports。config.resolve?.alias ?? {}
ts
// remocn components import each other through the "@/" alias in components.json.
// Bundlers don't read tsconfig paths, so the alias is resolved here as well.
// Both overrides are deliberate: the Remotion CLI applies overrideBundlerConfig
// with webpack and rspack alike, while Remocn Studio's preview reads only
// overrideWebpackConfig. Both run from the project root, which process.cwd()
// points at.
const withRemocnAlias = <C extends { resolve?: object }>(config: C): C => ({
...config,
resolve: {
...config.resolve,
alias: {
...((config.resolve as { alias?: object } | undefined)?.alias ?? {}),
"@": path.join(process.cwd(), "src"),
},
},
});
// overrideBundlerConfig only exists in newer Remotion 4 releases.
if (typeof Config.overrideBundlerConfig === "function") {
Config.overrideBundlerConfig(withRemocnAlias);
}
Config.overrideWebpackConfig(withRemocnAlias);当上述 alias 目标不同时,将 替换为对应的 alias 目标。
path.join(process.cwd(), "src")4. Report
4. 报告
Tell the user, in a few lines, what each step did: created, changed or left as it was, plus anything
they have to add by hand. Then works in the project.
npx shadcn@latest add @remocn/<name>用几行向用户说明每个步骤做了什么:创建、修改或保持不变的内容,以及用户必须手动添加的任何内容。之后, 即可在该项目中运行。
npx shadcn@latest add @remocn/<name>