lerna create <name>
开启yarn workspace 会检查每个子项目里面依赖及其版本,如果版本不一样则会留在子项目自己的node_modules里面,只有完全一样的依赖才会提升到顶层。
// 顶层package.json
{
"workspaces": [
"packages/*"
]
}
// lerna.json
{
"npmClient": "yarn",
"useWorkspaces": true
}
lerna add @miniprogrammonorepo/components --scope @miniprogrammonorepo/project1
import {something} from '@miniprogrammonorepo/components'
....
packages/components/node_modules
packages/project1/node_modules
packages/components/dist
packages/project1/dist
// vetur.config.js
/** @type {import('vls').VeturConfig} */
module.exports = {
// **optional** default: `{}`
// override vscode settings
// Notice: It only affects the settings used by Vetur.
settings: {
"vetur.useWorkspaceDependencies": true,
"vetur.experimental.templateInterpolationService": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
},
},
// **optional** default: `[{ root: './' }]`
// support monorepos
projects: [
{
root: "./packages/components",
package: "./package.json",
tsconfig: "./tsconfig.json",
},
{
root: "./packages/project1",
package: "./package.json",
tsconfig: "./tsconfig.json",
},
],
};
Lerna的Monorepo实战
Lerna指令总览 (Commands)
排忧解难
GitLab CI流水线配置文件.gitlab-ci.yml详解