File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
packages/taro-platform-h5/src Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,16 @@ export default class H5 extends TaroPlatformWeb {
224224 const viteCompilerContext = await getViteH5CompilerContext ( this )
225225 if ( viteCompilerContext ) {
226226 const exts = Array . from ( new Set ( viteCompilerContext . frameworkExts . concat ( SCRIPT_EXT ) ) )
227- if ( id . startsWith ( viteCompilerContext . sourceDir ) && exts . some ( ( ext ) => id . includes ( ext ) ) ) {
227+ let cleanId = id
228+
229+ if ( cleanId . startsWith ( '\u0000' ) ) {
230+ cleanId = cleanId . slice ( 1 )
231+ }
232+
233+ cleanId = cleanId . split ( '?' ) [ 0 ] . replace ( / \\ / g, '/' ) // 👈 替换斜杠方向
234+
235+ const normalizedSourceDir = viteCompilerContext . sourceDir . replace ( / \\ / g, '/' ) // 👈 替换斜杠方向
236+ if ( cleanId . startsWith ( normalizedSourceDir ) && exts . some ( ( ext ) => id . includes ( ext ) ) ) {
228237 // @TODO 后续考虑使用 SWC 插件的方式实现
229238 const result = await transformAsync ( code , {
230239 filename : id ,
You can’t perform that action at this time.
0 commit comments