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.