|
135 | 135 | #### 安装依赖
|
136 | 136 |
|
137 | 137 | ```
|
138 |
| -npm install // yarn |
| 138 | +pnpm install |
139 | 139 | ```
|
140 | 140 |
|
141 | 141 | #### 运行
|
142 | 142 |
|
143 | 143 | ```
|
144 |
| -npm run dev // yarn dev |
| 144 | +pnpm run dev |
| 145 | +``` |
| 146 | + |
| 147 | +关于执行指令的说明: |
| 148 | + |
| 149 | +```json |
| 150 | +"scripts": { |
| 151 | + "dev": "vite", |
| 152 | + /** |
| 153 | + 1、run-p 是 npm-run-all 包提供的一个命令,用于并行执行多个 npm 脚本,如果type-check失败,不会阻止vite build |
| 154 | + 2、type-check是一个用于在 Vue.js 项目中执行 TypeScript 类型检查的命令,它不会生成任何实际的编译输出文件,只进行类型检查。比如类型不匹配,属性不存在等 |
| 155 | + 3、vue-tsc --noEmit 默认会使用项目根目录下的 tsconfig.json 文件进行类型检查。 |
| 156 | + 4、如果想要在类型检查失败,构建命令不执行,可以改成run-s(串联),或者 npm run type-check && vite build |
| 157 | + */ |
| 158 | + "build": "run-p type-check build-only", |
| 159 | + "build-only": "vite build", |
| 160 | + "prepare": "husky install", |
| 161 | + "type-check": "vue-tsc --noEmit", |
| 162 | + "changelog": "conventional-changelog -p custom-config -i CHANGELOG.md -s -r 0 -n ./changelog.config.js", |
| 163 | + |
| 164 | + /** |
| 165 | + 运行后,对暂存区内容进行eslint和stylelint校验。校验配置如下: |
| 166 | + "lint-staged": { |
| 167 | + "*.{vue,ts,tsx,js,jsx,json}": [ |
| 168 | + "eslint --cache --quiet" |
| 169 | + ], |
| 170 | + "*.{css,less,vue}": [ |
| 171 | + "stylelint --cache --quiet" |
| 172 | + ] |
| 173 | + } |
| 174 | + */ |
| 175 | + "lint-staged": "lint-staged", |
| 176 | + |
| 177 | + |
| 178 | + /** |
| 179 | + 对整个项目进行eslint校验,但是不自动修复 |
| 180 | + */ |
| 181 | + "lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ext .vue,.ts,.tsx,.js,.jsx,.json --quiet src/", |
| 182 | + /** |
| 183 | + 对整个项目进行eslint校验,自动修复可以修复的。 |
| 184 | + */ |
| 185 | + "lint:fix": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ext .vue,.ts,.tsx,.js,.jsx,.json --quiet src/ --fix", |
| 186 | + |
| 187 | + /** |
| 188 | + 对整个项目进行stylelint校验,但是不自动修复 |
| 189 | + */ |
| 190 | + "stylelint": "stylelint \"src/**/*.{css,less,vue}\" --cache --cache-location node_modules/.cache/.stylelintcache", |
| 191 | + |
| 192 | + /** |
| 193 | + 对整个项目进行stylelint校验,但是不自动修复 |
| 194 | + */ |
| 195 | + "stylelint:fix": "stylelint \"src/**/*.{css,less,vue}\" --cache --cache-location node_modules/.cache/.stylelintcache --fix" |
| 196 | + }, |
145 | 197 | ```
|
146 | 198 |
|
147 | 199 | #### 构建
|
148 | 200 |
|
149 | 201 | ```
|
150 |
| -npm run build // yarn build |
| 202 | +pnpm run build |
151 | 203 | ```
|
0 commit comments