From 239ebe6cf3246ecfdb40a70f7270be406e5c322b Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 30 May 2023 17:06:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E8=BE=A3=E9=B8=A1windows?= =?UTF-8?q?=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/prod.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/prod.js b/lib/prod.js index 313a69d..fda4a0c 100644 --- a/lib/prod.js +++ b/lib/prod.js @@ -4,6 +4,9 @@ import Es from 'esbuild' import { compileScss, parseJs, compileVue, parseHtml } from './compile-vue.js' import { isCustomElement } from './utils.js' +const IS_WIN = process.platform === 'win32' +const PREFIX = IS_WIN ? 'pages\\' : 'pages/' + function readFile(file) { return (file && fs.cat(file)?.toString()) || '' } @@ -14,7 +17,9 @@ export default function compile(root = '', dist = '', conf = {}, verbose) { const PUBLIC_DIR = join(root, 'public') const DEPLOY_PATH = conf.base || '' // 部署目录, 默认是根目录部署 const IS_MPA = Object.keys(conf.pages).length > 1 - const PAGES_PREFIX = Object.keys(conf.pages).map(it => `pages/${it}/`) + const PAGES_PREFIX = Object.keys(conf.pages).map(it => + IS_WIN ? `${PREFIX + it}\\` : `${PREFIX + it}/` + ) const INJECT_SCSS = readFile(conf.inject?.scss) const LEGACY_MODE = !!conf.legacy @@ -36,7 +41,7 @@ export default function compile(root = '', dist = '', conf = {}, verbose) { ext: parse(name).ext } if (it.ext !== '') { - if (IS_MPA && it.name.startsWith('pages/')) { + if (IS_MPA && it.name.startsWith(PREFIX)) { if (PAGES_PREFIX.some(it => it.startsWith(it.name))) { return (list[path] = it) } else {