|
пре 10 месеци | |
---|---|---|
.hbuilderx | пре 11 месеци | |
.husky | пре 11 месеци | |
.vscode | пре 10 месеци | |
build | пре 10 месеци | |
src | пре 10 месеци | |
types | пре 10 месеци | |
.env.development | пре 10 месеци | |
.env.production | пре 10 месеци | |
.env.test | пре 10 месеци | |
.eslintignore | пре 11 месеци | |
.eslintrc | пре 10 месеци | |
.gitignore | пре 11 месеци | |
.npmrc | пре 11 месеци | |
.stylelintrc.js | пре 11 месеци | |
README.md | пре 10 месеци | |
commitlint.config.js | пре 11 месеци | |
index.html | пре 11 месеци | |
package.json | пре 10 месеци | |
pages.config.ts | пре 10 месеци | |
pnpm-lock.yaml | пре 10 месеци | |
prettier.config.js | пре 11 месеци | |
tsconfig.json | пре 10 месеци | |
uni-pages.d.ts | пре 10 месеци | |
uno.config.ts | пре 10 месеци | |
vite.config.ts | пре 10 месеци |
hbuilderx 创建模板工程 + 第三方依赖支持。
使用 vscode 编辑,提交代码,hbuilderx 运行和构建。
可以使用 dev:h5
模式来加快开发调试进度,但最终还需要以手机模拟器和真机的运行效果为准。
nodejs >= 18,如 v18.14.2 pnpm >= 9,如 v9.1.4
pnpm install
pnpm dev:h5
本项目已经配置好完整的husky及相关校验工具,此处用于记录
安装 husky
pnpm add husky@8.0.3 -D
配置 package.json
配置该脚本后,install 后会自动执行该命令
script : { "prepare": "husky install" }
添加 git 钩子
npx husky add .husky/pre-commit "pnpm pre-commit"
安装 lint-staged
用于只检查暂存区的文件
pnpm add lint-staged -D
配置 lint-staged
"lint-staged": {
"*.{vue,js,ts,jsx,tsx}": [
"pnpm format",
"pnpm lint"
],
"*.{css,scss,vue,html}": [
"pnpm format",
"pnpm lint:style"
]
}
安装 eslint 和配置
配置 lint 脚本命令
添加 husky commit 钩子
npx husky add .husky/pre-commit "npm run lint"
安装和配置 commitlint
添加 husky commit type校验 钩子
npx husky add .husky/commit-msg "npx --no-install commitlint --edit $HUSKY_GIT_PARAMS"
问题1: husky 不生效?
找到项目的.git 文件,查看是否有hooks目录及文件,没有的话,手动安装husky;如有hooks目录,尝试删除该目录后卸载husky后重新安装,重新设置husky钩子函数