[ci] yarn format

This commit is contained in:
matthewp 2021-11-22 21:17:58 +00:00 committed by GitHub Actions
parent 8cb779594e
commit 1304518b74
2 changed files with 21 additions and 16 deletions

View file

@ -354,10 +354,14 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
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({
insertBefore(
script.parentNode,
createScript({
...attrs,
src: relPath
}), script);
src: relPath,
}),
script
);
remove(script);
}
}

View file

@ -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,7 +32,7 @@ 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') {