11import path from 'node:path'
22
3- import { fs , isEmptyObject } from '@tarojs/helper'
3+ import { fs , isEmptyObject , normalizePath } from '@tarojs/helper'
44
55import { getDefaultPostcssConfig } from '../postcss/postcss.h5'
66import { appendVirtualModulePrefix , generateQueryString , getMode , getQueryParams } from '../utils'
@@ -14,15 +14,15 @@ export default function (viteCompilerContext: ViteH5CompilerContext): PluginOpti
1414 const { taroConfig, app } = viteCompilerContext
1515 const routerConfig = taroConfig . router || { }
1616 const isProd = getMode ( taroConfig ) === 'production'
17-
17+ const configPath = normalizePath ( app . configPath )
1818 return {
1919 name : 'taro:vite-h5-entry' ,
2020 enforce : 'pre' ,
2121
2222 async resolveId ( source , importer , options ) {
2323 // mpa 模式关于 入口脚本文件 的处理已经解藕到 mpa.ts
2424 const resolved = await this . resolve ( source , importer , { ...options , skipSelf : true } )
25- if ( resolved ?. id && resolved . id === app . configPath ) {
25+ if ( resolved ?. id && resolved . id === configPath ) {
2626 const params = {
2727 [ ENTRY_QUERY ] : 'true'
2828 }
@@ -152,7 +152,7 @@ export default function (viteCompilerContext: ViteH5CompilerContext): PluginOpti
152152 'import "@tarojs/components/global.css"' ,
153153 'import { initPxTransform } from "@tarojs/taro"' ,
154154 `import { ${ routerCreator } , ${ historyCreator } , ${ appMountHandler } } from "@tarojs/router"` ,
155- `import component from "${ app . scriptPath } "` ,
155+ `import component from "${ normalizePath ( app . scriptPath ) } "` ,
156156 'import { window } from "@tarojs/runtime"' ,
157157 `import { ${ creator } } from "${ creatorLocation } "` ,
158158 importFrameworkStatement ,
0 commit comments