Merge branch 'dev' into next
This commit is contained in:
@@ -6,12 +6,14 @@ import {
|
||||
readFileSync,
|
||||
outputFileSync,
|
||||
} from 'fs-extra';
|
||||
import merge from 'webpack-merge';
|
||||
import {
|
||||
SRC_DIR,
|
||||
getVantConfig,
|
||||
ROOT_WEBPACK_CONFIG_FILE,
|
||||
ROOT_POSTCSS_CONFIG_FILE,
|
||||
} from './constant';
|
||||
import { WebpackConfig } from './types';
|
||||
|
||||
export const EXT_REGEXP = /\.\w+$/;
|
||||
export const SFC_REGEXP = /\.(vue)$/;
|
||||
@@ -100,21 +102,23 @@ export function normalizePath(path: string): string {
|
||||
return path.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
export function getWebpackConfig(): object {
|
||||
export function getWebpackConfig(defaultConfig: WebpackConfig): WebpackConfig {
|
||||
if (existsSync(ROOT_WEBPACK_CONFIG_FILE)) {
|
||||
const config = require(ROOT_WEBPACK_CONFIG_FILE);
|
||||
|
||||
// 如果是函数形式,可能并不仅仅是添加额外的处理流程,而是在原有流程上进行修改
|
||||
// 比如修改markdown-loader,添加options.enableMetaData
|
||||
if (typeof config === 'function') {
|
||||
return config();
|
||||
return config(defaultConfig);
|
||||
}
|
||||
|
||||
return config;
|
||||
return merge(defaultConfig, config);
|
||||
}
|
||||
|
||||
return {};
|
||||
return defaultConfig;
|
||||
}
|
||||
|
||||
export function getPostcssConfig(): object {
|
||||
export function getPostcssConfig() {
|
||||
if (existsSync(ROOT_POSTCSS_CONFIG_FILE)) {
|
||||
return require(ROOT_POSTCSS_CONFIG_FILE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user