From 32d86454f3319e41e3a8b555af59ad76c4b9833b Mon Sep 17 00:00:00 2001 From: star sky <1176789241@qq.com> Date: Tue, 28 Sep 2021 22:24:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20run=20=E2=80=9Dyarn=20dev=E2=80=9C=20err?= =?UTF-8?q?or=20in=20window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/watchAndCopy.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/watchAndCopy.js b/scripts/watchAndCopy.js index 806b41cd..cb840752 100644 --- a/scripts/watchAndCopy.js +++ b/scripts/watchAndCopy.js @@ -1,18 +1,26 @@ const fs = require('fs-extra') const chokidar = require('chokidar') +const { normalizePath } = require('vite') function toClientAndNode(method, file) { + const normalize_file = normalizePath(file) if (method === 'copy') { - fs.copy(file, file.replace(/^src\/shared\//, 'src/node/')) - fs.copy(file, file.replace(/^src\/shared\//, 'src/client/')) + fs.copy( + normalize_file, + normalize_file.replace(/^src\/shared\//, 'src/node/') + ) + fs.copy( + normalize_file, + normalize_file.replace(/^src\/shared\//, 'src/client/') + ) } else if (method === 'remove') { - fs.remove(file.replace(/^src\/shared\//, 'src/node/')) - fs.remove(file.replace(/^src\/shared\//, 'src/client/')) + fs.remove(normalize_file.replace(/^src\/shared\//, 'src/node/')) + fs.remove(normalize_file.replace(/^src\/shared\//, 'src/client/')) } } function toDist(file) { - return file.replace(/^src\//, 'dist/') + return normalizePath(file).replace(/^src\//, 'dist/') } // copy shared files to the client and node directory whenever they change.