feat(cli): support custom postcss config
This commit is contained in:
@@ -22,7 +22,8 @@ export const DOCS_DIR = join(ROOT, 'docs');
|
||||
export const SITE_DIST_DIR = join(ROOT, 'site');
|
||||
export const VANT_CONFIG_FILE = join(ROOT, 'vant.config.js');
|
||||
export const PACKAGE_JSON_FILE = join(ROOT, 'package.json');
|
||||
export const WEBPACK_CONFIG_FILE = join(ROOT, 'webpack.config.js');
|
||||
export const ROOT_WEBPACK_CONFIG_FILE = join(ROOT, 'webpack.config.js');
|
||||
export const ROOT_POSTCSS_CONFIG_FILE = join(ROOT, 'postcss.config.js');
|
||||
|
||||
export const DIST_DIR = join(__dirname, '../../dist');
|
||||
export const CONFIG_DIR = join(__dirname, '../config');
|
||||
|
||||
@@ -7,7 +7,12 @@ import {
|
||||
readFileSync,
|
||||
outputFileSync
|
||||
} from 'fs-extra';
|
||||
import { SRC_DIR, getVantConfig, WEBPACK_CONFIG_FILE } from './constant';
|
||||
import {
|
||||
SRC_DIR,
|
||||
getVantConfig,
|
||||
ROOT_WEBPACK_CONFIG_FILE,
|
||||
ROOT_POSTCSS_CONFIG_FILE
|
||||
} from './constant';
|
||||
|
||||
export const EXT_REGEXP = /\.\w+$/;
|
||||
export const SFC_REGEXP = /\.(vue)$/;
|
||||
@@ -96,8 +101,8 @@ export function normalizePath(path: string): string {
|
||||
}
|
||||
|
||||
export function getWebpackConfig(): object {
|
||||
if (existsSync(WEBPACK_CONFIG_FILE)) {
|
||||
const config = require(WEBPACK_CONFIG_FILE);
|
||||
if (existsSync(ROOT_WEBPACK_CONFIG_FILE)) {
|
||||
const config = require(ROOT_WEBPACK_CONFIG_FILE);
|
||||
|
||||
if (typeof config === 'function') {
|
||||
return config();
|
||||
@@ -109,6 +114,14 @@ export function getWebpackConfig(): object {
|
||||
return {};
|
||||
}
|
||||
|
||||
export function getPostcssConfig(): object {
|
||||
if (existsSync(ROOT_POSTCSS_CONFIG_FILE)) {
|
||||
return require(ROOT_POSTCSS_CONFIG_FILE);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
export type ModuleEnv = 'esmodule' | 'commonjs';
|
||||
export type NodeEnv = 'production' | 'development' | 'test';
|
||||
export type BuildTarget = 'site' | 'package';
|
||||
@@ -129,8 +142,8 @@ export function isDev() {
|
||||
return process.env.NODE_ENV === 'development';
|
||||
}
|
||||
|
||||
// Smarter outputFileSync
|
||||
// Skip if content unchanged
|
||||
// smarter outputFileSync
|
||||
// skip output if file content unchanged
|
||||
export function smartOutputFile(filePath: string, content: string) {
|
||||
if (existsSync(filePath)) {
|
||||
const previousContent = readFileSync(filePath, 'utf-8');
|
||||
|
||||
Reference in New Issue
Block a user