Skip to content
On this page

yarn

创建 Vue CLI 项目时

  1. 创建项目过程应选 ✔️Sass、✔️yarn,绝对不选 ❌ESLint。接手别人的工程必须删除ESLint相关的所有依赖,再安装项目。

  2. Vue CLI 项目不要使用 git 钩子,因为可以绕开。本地端应依赖 VS Code 保存时自动格式化来规范代码,服务器端应依赖 Gitlab 的钩子来规范代码。

创建 .yarnrc

为了约束合作程序员必须使用淘宝源,项目根目录必须创建.yarnrc,内容至少有:

registry "https://registry.npm.taobao.org"
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "https://cnpmjs.org/downloads"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"

package.json 的 resolutions 字段

由于imagemin在国内不好安装,可以在 package.json 内配置:

js
"resolutions": {
  "bin-wrapper": "npm:bin-wrapper-china"
},

杨亮的前端解决方案