feat(cli): restart compile when vant config updated

This commit is contained in:
陈嘉涵
2019-12-04 18:10:14 +08:00
parent 2db6e2a44d
commit b19b287276
11 changed files with 152 additions and 105 deletions
+21 -1
View File
@@ -1,7 +1,13 @@
import decamelize from 'decamelize';
import { join } from 'path';
import { get } from 'lodash';
import { readdirSync, existsSync, lstatSync, readFileSync } from 'fs-extra';
import {
lstatSync,
existsSync,
readdirSync,
readFileSync,
outputFileSync
} from 'fs-extra';
import { CONFIG, SRC_DIR, WEBPACK_CONFIG_FILE } from './constant';
export const EXT_REGEXP = /\.\w+$/;
@@ -114,4 +120,18 @@ export function getCssLang(): string {
return preprocessor;
}
// Smarter outputFileSync
// Skip if content unchanged
export function smartOutputFile(filePath: string, content: string) {
if (existsSync(filePath)) {
const previousContent = readFileSync(filePath, 'utf-8');
if (previousContent === content) {
return;
}
}
outputFileSync(filePath, content);
}
export { decamelize };