Skip to content

Commit

Permalink
fix(vite-runner): 修复Windows环境下使用vite构建时路径错误 (#16971)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsFaser authored Dec 2, 2024
1 parent 0828d8d commit 14ac834
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/taro-vite-runner/src/utils/html.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { normalizePath } from '@tarojs/helper'

export function getHtmlScript (entryScript: string, pxtransformOption): string {
let htmlScript = ''
const options = pxtransformOption?.config || {}
Expand All @@ -11,6 +13,6 @@ export function getHtmlScript (entryScript: string, pxtransformOption): string {
if ((options?.targetUnit ?? 'rem') === 'rem') {
htmlScript = `<script>!function(n){function f(){var e=n.document.documentElement,r=e.getBoundingClientRect(),width=r.width,height=r.height,arr=[width,height].filter(function(value){return Boolean(value)}),w=Math.min.apply(Math,arr),x=${rootValue}*w/${designWidth};e.style.fontSize=x>=${max}?"${max}px":x<=${min}?"${min}px":x+"px"}; n.addEventListener("resize",(function(){f()})),f()}(window);</script>\n`
}
htmlScript += ` <script type="module" src="${entryScript}"></script>`
htmlScript += ` <script type="module" src="${normalizePath(entryScript)}"></script>`
return htmlScript
}

0 comments on commit 14ac834

Please sign in to comment.