diff --git a/lib/main.js b/lib/main.js index c18ff4d..94fbd38 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,46 +27,43 @@ export default function compile(root = '', isProd = false, es) { chokidar .watch(SOURCE_DIR) .on('all', (act, filePath) => { - if (isProd || ready) { - let file = filePath.slice(SOURCE_DIR.length) - let target = join(DIST_DIR, file) + let file = filePath.slice(SOURCE_DIR.length) + let target = join(DIST_DIR, file) - if (act === 'add' || act === 'change') { - let ext = file.slice(file.lastIndexOf('.') + 1) + if (act === 'add' || act === 'change') { + let ext = file.slice(file.lastIndexOf('.') + 1) - switch (ext) { - case 'css': - case 'jpg': - case 'png': - case 'svg': - case 'json': - case 'gif': - case 'webp': - console.log('复制 %s ...', blue(file)) - fs.cp(filePath, target) - break + switch (ext) { + case 'css': + case 'jpg': + case 'png': + case 'svg': + case 'json': + case 'gif': + case 'webp': + console.log('复制 %s ...', blue(file)) + fs.cp(filePath, target) + break - case 'js': - { - let code = fs.cat(filePath).toString() - console.log('编译 %s ...', blue(file)) - code = Es.transformSync(code, OPTIONS).code.replace( - /css`([\w\W]*?)`/g, - function (m, scss) { - scss = compileScss(scss) - return `css\`${scss}\`` - } - ) + case 'js': + { + let code = fs.cat(filePath).toString() + console.log('编译 %s ...', blue(file)) + code = Es.transformSync(code, OPTIONS).code.replace( + /css`([\w\W]*?)`/g, + function (m, scss) { + scss = compileScss(scss) + return `css\`${scss}\`` + } + ) - fs.echo(code, target) - } - break - } + fs.echo(code, target) + } + break } } }) .on('ready', () => { - ready = true if (isProd) { process.exit() } diff --git a/package.json b/package.json index 44b1280..04f6551 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@bd/wcui-cli", "type": "module", - "version": "1.0.0", + "version": "1.0.1", "bin": { "wcui-cli": "index.js" },