[ci] yarn format
This commit is contained in:
parent
8cb779594e
commit
1304518b74
2 changed files with 21 additions and 16 deletions
|
@ -114,9 +114,9 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
|
|||
frontEndImports.push(scriptId);
|
||||
astroScriptMap.set(scriptId, js);
|
||||
}
|
||||
} else if(isInSrcDirectory(script, 'src', srcRoot, srcRootWeb)) {
|
||||
} else if (isInSrcDirectory(script, 'src', srcRoot, srcRootWeb)) {
|
||||
const src = getAttribute(script, 'src');
|
||||
if(src) jsInput.add(src);
|
||||
if (src) jsInput.add(src);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,17 +347,21 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
|
|||
);
|
||||
}
|
||||
remove(script);
|
||||
} else if(isInSrcDirectory(script, 'src', srcRoot, srcRootWeb)) {
|
||||
} else if (isInSrcDirectory(script, 'src', srcRoot, srcRootWeb)) {
|
||||
const src = getAttribute(script, 'src');
|
||||
// On windows the facadeId doesn't start with / but does not Unix :/
|
||||
if(src && (facadeIdMap.has(src) || facadeIdMap.has(src.substr(1)))) {
|
||||
if (src && (facadeIdMap.has(src) || facadeIdMap.has(src.substr(1)))) {
|
||||
const assetRootPath = '/' + (facadeIdMap.get(src) || facadeIdMap.get(src.substr(1)));
|
||||
const relPath = npath.posix.relative(pathname, assetRootPath);
|
||||
const attrs = getAttributes(script);
|
||||
insertBefore(script.parentNode, createScript({
|
||||
...attrs,
|
||||
src: relPath
|
||||
}), script);
|
||||
insertBefore(
|
||||
script.parentNode,
|
||||
createScript({
|
||||
...attrs,
|
||||
src: relPath,
|
||||
}),
|
||||
script
|
||||
);
|
||||
remove(script);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import { getAttribute, hasAttribute, getTagName } from '@web/parse5-utils';
|
||||
import parse5 from 'parse5';
|
||||
import { isStylesheetLink } from './extract-assets.js';
|
||||
|
@ -6,15 +5,17 @@ import { isStylesheetLink } from './extract-assets.js';
|
|||
const tagsWithSrcSet = new Set(['img', 'source']);
|
||||
|
||||
function startsWithSrcRoot(pathname: string, srcRoot: string, srcRootWeb: string): boolean {
|
||||
return pathname.startsWith(srcRoot) // /Users/user/project/src/styles/main.css
|
||||
|| pathname.startsWith(srcRootWeb) // /src/styles/main.css
|
||||
|| `/${pathname}`.startsWith(srcRoot); // Windows fix: some paths are missing leading "/"
|
||||
return (
|
||||
pathname.startsWith(srcRoot) || // /Users/user/project/src/styles/main.css
|
||||
pathname.startsWith(srcRootWeb) || // /src/styles/main.css
|
||||
`/${pathname}`.startsWith(srcRoot)
|
||||
); // Windows fix: some paths are missing leading "/"
|
||||
}
|
||||
|
||||
export function isInSrcDirectory(node: parse5.Element, attr: string, srcRoot: string, srcRootWeb: string): boolean {
|
||||
const value = getAttribute(node, attr);
|
||||
return value ? startsWithSrcRoot(value, srcRoot, srcRootWeb) : false;
|
||||
};
|
||||
}
|
||||
|
||||
export function isAstroInjectedLink(node: parse5.Element): boolean {
|
||||
return isStylesheetLink(node) && getAttribute(node, 'data-astro-injected') === '';
|
||||
|
@ -31,10 +32,10 @@ export function isBuildableLink(node: parse5.Element, srcRoot: string, srcRootWe
|
|||
}
|
||||
|
||||
return startsWithSrcRoot(href, srcRoot, srcRootWeb);
|
||||
};
|
||||
}
|
||||
|
||||
export function isBuildableImage(node: parse5.Element, srcRoot: string, srcRootWeb: string): boolean {
|
||||
if(getTagName(node) === 'img') {
|
||||
if (getTagName(node) === 'img') {
|
||||
const src = getAttribute(node, 'src');
|
||||
return src ? startsWithSrcRoot(src, srcRoot, srcRootWeb) : false;
|
||||
}
|
||||
|
@ -47,4 +48,4 @@ export function hasSrcSet(node: parse5.Element): boolean {
|
|||
|
||||
export function isHoistedScript(node: parse5.Element): boolean {
|
||||
return getTagName(node) === 'script' && hasAttribute(node, 'hoist');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue