minista 3.1.11 → 3.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { normalizePath } from "vite";
|
|
2
3
|
import { flags } from "../config/system.js";
|
|
3
4
|
import { cleanElement } from "../utility/element.js";
|
|
4
5
|
import { getHtmlPath } from "../utility/path.js";
|
|
@@ -8,10 +9,12 @@ function getRelativePath({
|
|
|
8
9
|
replaceTarget,
|
|
9
10
|
assetPath
|
|
10
11
|
}) {
|
|
11
|
-
const pagePath = path.dirname(getHtmlPath(pathname));
|
|
12
|
+
const pagePath = path.dirname(getHtmlPath(pathname)).replace(/^[\\]+/, ".");
|
|
12
13
|
let resolvedPath = assetPath.replace(/\n/, "").trim();
|
|
13
14
|
if (!resolvedPath.includes(",") && resolvedPath.startsWith(replaceTarget)) {
|
|
14
|
-
return
|
|
15
|
+
return normalizePath(
|
|
16
|
+
path.relative(pagePath, resolvedPath.replace(/^[\/\\]+/, ""))
|
|
17
|
+
);
|
|
15
18
|
}
|
|
16
19
|
if (!resolvedPath.includes(",")) {
|
|
17
20
|
return resolvedPath;
|
|
@@ -19,7 +22,9 @@ function getRelativePath({
|
|
|
19
22
|
resolvedPath = resolvedPath.split(",").map((s) => s.trim()).map((s) => {
|
|
20
23
|
let [url, density] = s.split(/\s+/);
|
|
21
24
|
if (url.startsWith(replaceTarget)) {
|
|
22
|
-
url =
|
|
25
|
+
url = normalizePath(
|
|
26
|
+
path.relative(pagePath, path.join("./", url).replace(/^[\/\\]+/, ""))
|
|
27
|
+
);
|
|
23
28
|
}
|
|
24
29
|
return `${url} ${density}`;
|
|
25
30
|
}).join(", ");
|
|
@@ -55,7 +60,7 @@ function transformRelative({
|
|
|
55
60
|
if (assetPath) {
|
|
56
61
|
const relativePaths = getRelativePath({
|
|
57
62
|
pathname,
|
|
58
|
-
replaceTarget: path.join("/", outDir),
|
|
63
|
+
replaceTarget: normalizePath(path.join("/", outDir)),
|
|
59
64
|
assetPath
|
|
60
65
|
});
|
|
61
66
|
el.setAttribute(attr, relativePaths);
|