mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 11:54:02 +00:00
chore(@vant/cli): remove build --watch option
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import execa from 'execa';
|
||||
import chokidar from 'chokidar';
|
||||
import { join, relative } from 'path';
|
||||
import { remove, copy, readdirSync, existsSync } from 'fs-extra';
|
||||
import { clean } from './clean';
|
||||
import { CSS_LANG } from '../common/css';
|
||||
import { ora, consola, slimPath } from '../common/logger';
|
||||
import { ora, consola } from '../common/logger';
|
||||
import { installDependencies } from '../common/manager';
|
||||
import { compileJs } from '../compiler/compile-js';
|
||||
import { compileSfc } from '../compiler/compile-sfc';
|
||||
@@ -181,44 +180,13 @@ async function runBuildTasks() {
|
||||
consola.success('Compile successfully');
|
||||
}
|
||||
|
||||
function watchFileChange() {
|
||||
consola.info('Watching file changes...');
|
||||
|
||||
chokidar.watch(SRC_DIR).on('change', async (path) => {
|
||||
if (isDemoDir(path) || isTestDir(path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const spinner = ora('File changed, start compilation...').start();
|
||||
const esPath = path.replace(SRC_DIR, ES_DIR);
|
||||
const libPath = path.replace(SRC_DIR, LIB_DIR);
|
||||
|
||||
try {
|
||||
await copy(path, esPath);
|
||||
await copy(path, libPath);
|
||||
await compileFile(esPath);
|
||||
await compileFile(libPath);
|
||||
await genStyleDepsMap();
|
||||
genComponentStyle({ cache: false });
|
||||
spinner.succeed('Compiled: ' + slimPath(path));
|
||||
} catch (err) {
|
||||
spinner.fail('Compile failed: ' + path);
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function build(cmd: { watch?: boolean } = {}) {
|
||||
export async function build() {
|
||||
setNodeEnv('production');
|
||||
|
||||
try {
|
||||
await clean();
|
||||
await installDependencies();
|
||||
await runBuildTasks();
|
||||
|
||||
if (cmd.watch) {
|
||||
watchFileChange();
|
||||
}
|
||||
} catch (err) {
|
||||
consola.error('Build failed');
|
||||
process.exit(1);
|
||||
|
Reference in New Issue
Block a user