From bf082f1fdf5a3050b56c0ee862eebd2224892381 Mon Sep 17 00:00:00 2001 From: winixt Date: Wed, 22 Jun 2022 10:40:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20build=20watch=20copy=20=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E8=AF=86=E5=88=AB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-layout/src/runtime/index.js | 4 +--- scripts/build.mjs | 7 ++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/fes-plugin-layout/src/runtime/index.js b/packages/fes-plugin-layout/src/runtime/index.js index 61271e73..72f0ee5a 100644 --- a/packages/fes-plugin-layout/src/runtime/index.js +++ b/packages/fes-plugin-layout/src/runtime/index.js @@ -1,3 +1 @@ -import page from './views/page.vue'; - -export const Page = page; +export { default as Page } from './views/page.vue'; diff --git a/scripts/build.mjs b/scripts/build.mjs index 39eee819..27e2ceec 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -69,7 +69,9 @@ async function getPkgConfig(config, pkgName) { const pkgConfigPath = path.join(getPkgPath(pkgName), CONFIG_FILE_NAME); if (fs.existsSync(pkgConfigPath)) { const content = await import(process.platform === 'win32' ? `file://${pkgConfigPath}` : pkgConfigPath); - return merge(config, content.default); + const result = merge(config, content.default); + result.resolveCopy = result.copy.map((item) => path.join(getPkgPath(pkgName), 'src', item)); + return result; } return config; @@ -144,12 +146,11 @@ function watchFile(dir, outputDir, config, log) { }) .on('all', (event, changeFile) => { // 修改的可能是一个目录,一个文件,一个需要 copy 的文件 or 目录 - const baseName = path.basename(changeFile); const shortChangeFile = genShortPath(changeFile); const outputPath = changeFile.replace(dir, outputDir); const stat = fs.lstatSync(changeFile); log(`[${event}] ${shortChangeFile}`); - if (config.copy.includes(baseName)) { + if (config.resolveCopy.some((item) => changeFile.startsWith(item))) { fse.copySync(changeFile, outputPath); } else if (stat.isFile()) { transformFile(changeFile, outputPath, config, log);