[ci] format
This commit is contained in:
parent
fbef6a7f72
commit
8b468ccccc
2 changed files with 15 additions and 13 deletions
|
@ -619,7 +619,7 @@ export function spreadAttributes(
|
|||
}
|
||||
|
||||
// Adds CSS variables to an inline style tag
|
||||
export function defineStyleVars(defs: Record<any, any>|Record<any, any>[]) {
|
||||
export function defineStyleVars(defs: Record<any, any> | Record<any, any>[]) {
|
||||
let output = '';
|
||||
let arr = !Array.isArray(defs) ? [defs] : defs;
|
||||
for (const vars of arr) {
|
||||
|
@ -634,10 +634,10 @@ export function defineStyleVars(defs: Record<any, any>|Record<any, any>[]) {
|
|||
|
||||
// converts (most) arbitrary strings to valid JS identifiers
|
||||
const toIdent = (k: string) =>
|
||||
k.trim().replace(/(?:(?<!^)\b\w|\s+|[^\w]+)/g, (match, index) => {
|
||||
if (/[^\w]|\s/.test(match)) return '';
|
||||
return index === 0 ? match : match.toUpperCase();
|
||||
});
|
||||
k.trim().replace(/(?:(?<!^)\b\w|\s+|[^\w]+)/g, (match, index) => {
|
||||
if (/[^\w]|\s/.test(match)) return '';
|
||||
return index === 0 ? match : match.toUpperCase();
|
||||
});
|
||||
|
||||
// Adds variables to an inline script.
|
||||
export function defineScriptVars(vars: Record<any, any>) {
|
||||
|
|
|
@ -179,25 +179,25 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
|
|||
code: '',
|
||||
meta: {
|
||||
vite: {
|
||||
lang: 'ts'
|
||||
}
|
||||
}
|
||||
lang: 'ts',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
switch (hoistedScript.type) {
|
||||
case 'inline': {
|
||||
let { code, map } = hoistedScript
|
||||
let { code, map } = hoistedScript;
|
||||
result.code = appendSourceMap(code, map);
|
||||
break;
|
||||
}
|
||||
case 'external': {
|
||||
const { src } = hoistedScript
|
||||
const { src } = hoistedScript;
|
||||
result.code = `import "${src}"`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
|
@ -364,5 +364,7 @@ ${source}
|
|||
|
||||
function appendSourceMap(content: string, map?: string) {
|
||||
if (!map) return content;
|
||||
return `${content}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(map).toString('base64')}`
|
||||
return `${content}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(
|
||||
map
|
||||
).toString('base64')}`;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue