mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 19:24:16 +00:00
feat(cli): restart compile when vant config updated
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import { transformFileSync } from '@babel/core';
|
||||
import { transformFileAsync } from '@babel/core';
|
||||
import { removeSync, outputFileSync } from 'fs-extra';
|
||||
import { replaceExt } from '../common';
|
||||
|
||||
export function compileJs(filePath: string) {
|
||||
const result = transformFileSync(filePath);
|
||||
export function compileJs(filePath: string): Promise<undefined> {
|
||||
return new Promise((resolve, reject) => {
|
||||
transformFileAsync(filePath)
|
||||
.then(result => {
|
||||
if (result) {
|
||||
const jsFilePath = replaceExt(filePath, '.js');
|
||||
|
||||
if (result) {
|
||||
const jsFilePath = replaceExt(filePath, '.js');
|
||||
|
||||
removeSync(filePath);
|
||||
outputFileSync(jsFilePath, result.code);
|
||||
}
|
||||
removeSync(filePath);
|
||||
outputFileSync(jsFilePath, result.code);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user