From 0225e1e499afbeb97278b49353b6a75e210ac802 Mon Sep 17 00:00:00 2001 From: yutent Date: Sun, 25 Jun 2023 11:59:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E5=A4=84=E7=AC=94?= =?UTF-8?q?=E8=AF=AF;=20=E4=BF=AE=E6=AD=A3js=E8=A7=A3=E6=9E=90=E8=A1=8C?= =?UTF-8?q?=E5=8F=B7;=E4=BF=AE=E5=A4=8Djs=E8=A7=A3=E6=9E=90=E6=97=B6?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E6=9C=AA=E4=BC=A0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/compile-vue.js | 2 +- lib/dev.js | 40 +++++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/compile-vue.js b/lib/compile-vue.js index 3fae656..ca0927f 100644 --- a/lib/compile-vue.js +++ b/lib/compile-vue.js @@ -112,7 +112,7 @@ export function parseJs( imports, { IS_MPA, currentPage, IS_ENTRY, DEPLOY_PATH, LEGACY_MODE } = {}, filename, - linePatch = 0 + linePatch = 1 ) { let fixedStyle = '' let ASSETS_DIR = '/@/' diff --git a/lib/dev.js b/lib/dev.js index 2ab47dd..1bc2b4b 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -166,13 +166,18 @@ export default async function createServer(root = '', conf = {}) { let entry = fs.cat(page.entry)?.toString() let html = fs.cat(join(process.cwd(), 'index.html')).toString() - entry = parseJs(entry, conf.imports, { - IS_MPA, - currentPage, - IS_ENTRY: true, - DEPLOY_PATH, - LEGACY_MODE - }) + entry = parseJs( + entry, + conf.imports, + { + IS_MPA, + currentPage, + IS_ENTRY: true, + DEPLOY_PATH, + LEGACY_MODE + }, + page.entry + ) code = parseHtml(html, { page, @@ -198,7 +203,6 @@ export default async function createServer(root = '', conf = {}) { file = join(SOURCE_DIR, rpath) } } else { - ndex.html file = join(SOURCE_DIR, rpath) } if (!fs.isfile(file)) { @@ -267,19 +271,25 @@ export default async function createServer(root = '', conf = {}) { if (fs.isfile(file)) { code = fs.cat(file) } else if (fs.isfile(join(PUBLIC_DIR, rpath))) { - code = fs.cat(join(PUBLIC_DIR, rpath)) + file = join(PUBLIC_DIR, rpath) + code = fs.cat(file) } else { friendlyErrors(rpath, ext) res.writeHead(404, USE_HTTPS ? void 0 : 'Not Found') res.end('') return } - code = parseJs(code + '', conf.imports, { - IS_MPA, - currentPage, - DEPLOY_PATH, - LEGACY_MODE - }) + code = parseJs( + code + '', + conf.imports, + { + IS_MPA, + currentPage, + DEPLOY_PATH, + LEGACY_MODE + }, + file + ) res.setHeader('content-type', MIME_TYPES.js) }