feat(@vant/cli): support custom vite config (#9738)

This commit is contained in:
neverland
2021-10-27 14:46:37 +08:00
committed by GitHub
parent 4778b07d40
commit 8585842712
5 changed files with 63 additions and 5 deletions
+12
View File
@@ -1,3 +1,4 @@
import { get } from 'lodash';
import { sep, join } from 'path';
import {
lstatSync,
@@ -7,6 +8,7 @@ import {
outputFileSync,
} from 'fs-extra';
import { SRC_DIR, getVantConfig } from './constant';
import type { InlineConfig } from 'vite';
export const EXT_REGEXP = /\.\w+$/;
export const SFC_REGEXP = /\.(vue)$/;
@@ -134,4 +136,14 @@ export function smartOutputFile(filePath: string, content: string) {
outputFileSync(filePath, content);
}
export function mergeCustomViteConfig(config: InlineConfig) {
const vantConfig = getVantConfig();
const configureVite = get(vantConfig, 'build.configureVite');
if (configureVite) {
return configureVite(config);
}
return config;
}
export { getVantConfig };