mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(@vant/cli): add build.packageManager config
This commit is contained in:
parent
08847af422
commit
ecd2fb4f13
@ -180,6 +180,13 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### build.packageManager
|
||||||
|
|
||||||
|
- Type: `'npm' | 'yarn' | 'pnpm'`
|
||||||
|
- Default: `undefined`
|
||||||
|
|
||||||
|
指定使用的包管理器。
|
||||||
|
|
||||||
### site.title
|
### site.title
|
||||||
|
|
||||||
- Type: `string`
|
- Type: `string`
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import fs from 'fs-extra';
|
|
||||||
import execa from 'execa';
|
import execa from 'execa';
|
||||||
import { join } from 'path';
|
|
||||||
import { consola } from './logger.js';
|
import { consola } from './logger.js';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import { ROOT } from './constant.js';
|
import { getVantConfig } from './constant.js';
|
||||||
|
|
||||||
let hasYarnCache: boolean;
|
let hasYarnCache: boolean;
|
||||||
|
|
||||||
@ -20,16 +18,21 @@ export function hasYarn() {
|
|||||||
return hasYarnCache;
|
return hasYarnCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUsingPnpm() {
|
function getPackageManager() {
|
||||||
const pnpmLock = join(ROOT, 'pnpm-lock.yaml');
|
const { build } = getVantConfig();
|
||||||
return fs.existsSync(pnpmLock);
|
|
||||||
|
if (build?.packageManager) {
|
||||||
|
return build?.packageManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasYarn() ? 'yarn' : 'npm';
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function installDependencies() {
|
export async function installDependencies() {
|
||||||
consola.info('Install Dependencies\n');
|
consola.info('Install Dependencies\n');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const manager = isUsingPnpm() ? 'pnpm' : hasYarn() ? 'yarn' : 'npm';
|
const manager = getPackageManager();
|
||||||
|
|
||||||
await execa(manager, ['install', '--prod=false'], {
|
await execa(manager, ['install', '--prod=false'], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
|
@ -4,6 +4,7 @@ export default {
|
|||||||
srcDir: 'src',
|
srcDir: 'src',
|
||||||
namedExport: true,
|
namedExport: true,
|
||||||
skipInstall: ['lazyload'],
|
skipInstall: ['lazyload'],
|
||||||
|
packageManager: 'pnpm',
|
||||||
site: {
|
site: {
|
||||||
publicPath:
|
publicPath:
|
||||||
(typeof window === 'undefined' && process.env.PUBLIC_PATH) ||
|
(typeof window === 'undefined' && process.env.PUBLIC_PATH) ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user