rsconfig & gen
This commit is contained in:
parent
26a0a3c2e0
commit
dae5cf96d8
35
readme.md
35
readme.md
|
|
@ -1,12 +1,33 @@
|
|||
# Unity Puerts 模板
|
||||
|
||||
工作方式
|
||||
## 工作方式
|
||||
|
||||
1. 正常npm项目,输出一个js bundle,与unity独立
|
||||
2. 依赖Unity生成的类型绑定,将打包放入同一目录的Resources文件夹内
|
||||
- 正常npm项目,输出一个js bundle,与unity独立
|
||||
- 依赖Unity生成的类型绑定,将打包放入同一目录的Resources文件夹内
|
||||
|
||||
安装配置
|
||||
## 安装配置
|
||||
|
||||
1. clone本仓库到unity项目外任意路径,npm install安装依赖
|
||||
1. 将Unity项目的`Assets/Gen` symlink到根目录下
|
||||
1. 配置`.gitignore`,忽略`Assets/Gen`文件夹内容
|
||||
- clone本仓库到unity项目外任意路径,npm install安装依赖
|
||||
- 将Unity项目的`Assets/Gen` symlink到根目录下
|
||||
- 配置`.gitignore`,忽略`Assets/Gen`文件夹内容
|
||||
|
||||
## 类型检查
|
||||
|
||||
- 虽然puerts生成的`CS.namespace.xxx`即使不作额外配置也能用,但没有自动补全
|
||||
- 为了使用自动补全,需要额外添加类型标注
|
||||
|
||||
- 在`modules.d.ts`中添加:
|
||||
|
||||
```typescript
|
||||
declare module "包名" {
|
||||
export = CS.包名;
|
||||
}
|
||||
```
|
||||
|
||||
- 在`rspack.config.ts`中添加额外的`externals`:
|
||||
|
||||
```typescript
|
||||
externals: {
|
||||
"包名": "CS.包名"
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import { defineConfig } from "@rspack/cli";
|
||||
import { resolve } from "path/win32";
|
||||
import { fileURLToPath } from "url";
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = resolve(__filename, "..");
|
||||
export default defineConfig({
|
||||
entry: {
|
||||
main: "./src/index.ts",
|
||||
|
|
@ -9,4 +13,8 @@ export default defineConfig({
|
|||
"unityengine/ui": "CS.UnityEngine.UI",
|
||||
"system": "CS.System",
|
||||
},
|
||||
output: {
|
||||
path: resolve(__dirname, "Gen/Resources"),
|
||||
filename: "[name].mjs",
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue