@hadss/hmrouter-plugin
v1.0.0-rc.5
Published
HMRouter Compiler Plugin
Downloads
455
Maintainers
Readme
编译插件配置
- 修改项目的
hvigor/hvigor-config.json
文件,加入路由编译插件
{
"dependencies": {
"@hadss/hmrouter-plugin": "^1.0.0-rc.4" // 使用npm仓版本号
},
// ...其他配置
}
- 在模块中引入路由编译插件,修改
hvigorfile.ts
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
import { hapPlugin } from '@hadss/hmrouter-plugin';
export default {
system: hapTasks,
plugins: [hapPlugin()] // 使用HMRouter框架中标签的模块均需要配置,与模块类型保持一致
}
如果模块是Har则使用
harPlugin()
, 模块是Hsp则使用hspPlugin()
- 项目根目录或者模块目录创建路由编译插件配置文件
hmrouter_config.json
(推荐)
{
// 如果不配置则扫描src/main/ets目录,对代码进行全量扫描,如果配置则数组不能为空,建议配置指定目录可缩短编译耗时
"scanDir": ["src/main/ets/components","src/main/ets/interceptors"],
"saveGeneratedFile": false, // 默认为false,调试排除错误时可以改成true,不删除编译产物
}
配置文件读取规则为 模块 > 工程 > 默认 优先使用本模块内的配置,如果没有配置,则找模块目录的上级目录(最多找三层目录,找到则停止),若找不到则使用默认配置