[ci] yarn format
This commit is contained in:
parent
20d0cce681
commit
babed02876
2 changed files with 16 additions and 16 deletions
|
@ -13,7 +13,11 @@ const ASTRO_STYLE_PREFIX = '@astro-inline-style';
|
||||||
|
|
||||||
const ASTRO_PAGE_STYLE_PREFIX = '@astro-page-all-styles';
|
const ASTRO_PAGE_STYLE_PREFIX = '@astro-page-all-styles';
|
||||||
|
|
||||||
const cssRe = new RegExp(`\\.(${Array.from(STYLE_EXTENSIONS).map(s => s.slice(1)).join('|')})($|\\?)`);
|
const cssRe = new RegExp(
|
||||||
|
`\\.(${Array.from(STYLE_EXTENSIONS)
|
||||||
|
.map((s) => s.slice(1))
|
||||||
|
.join('|')})($|\\?)`
|
||||||
|
);
|
||||||
const isCSSRequest = (request: string): boolean => cssRe.test(request);
|
const isCSSRequest = (request: string): boolean => cssRe.test(request);
|
||||||
|
|
||||||
export function getAstroPageStyleId(pathname: string) {
|
export function getAstroPageStyleId(pathname: string) {
|
||||||
|
@ -110,8 +114,6 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async renderChunk(_code, chunk) {
|
async renderChunk(_code, chunk) {
|
||||||
let chunkCSS = '';
|
let chunkCSS = '';
|
||||||
let isPureCSS = true;
|
let isPureCSS = true;
|
||||||
|
@ -143,7 +145,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
|
||||||
internals.chunkToReferenceIdMap.set(chunk.fileName, referenceId);
|
internals.chunkToReferenceIdMap.set(chunk.fileName, referenceId);
|
||||||
if (chunk.type === 'chunk') {
|
if (chunk.type === 'chunk') {
|
||||||
const fileName = this.getFileName(referenceId);
|
const fileName = this.getFileName(referenceId);
|
||||||
if(chunk.facadeModuleId) {
|
if (chunk.facadeModuleId) {
|
||||||
const facadeId = chunk.facadeModuleId!;
|
const facadeId = chunk.facadeModuleId!;
|
||||||
if (!internals.facadeIdToAssetsMap.has(facadeId)) {
|
if (!internals.facadeIdToAssetsMap.has(facadeId)) {
|
||||||
internals.facadeIdToAssetsMap.set(facadeId, []);
|
internals.facadeIdToAssetsMap.set(facadeId, []);
|
||||||
|
@ -170,17 +172,17 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
|
||||||
// If the chunk has a facadeModuleId it is an entrypoint chunk.
|
// If the chunk has a facadeModuleId it is an entrypoint chunk.
|
||||||
// This find shared chunks of CSS and adds them to the main CSS chunks,
|
// This find shared chunks of CSS and adds them to the main CSS chunks,
|
||||||
// so that shared CSS is added to the page.
|
// so that shared CSS is added to the page.
|
||||||
if(chunk.facadeModuleId) {
|
if (chunk.facadeModuleId) {
|
||||||
if(!internals.facadeIdToAssetsMap.has(chunk.facadeModuleId)) {
|
if (!internals.facadeIdToAssetsMap.has(chunk.facadeModuleId)) {
|
||||||
internals.facadeIdToAssetsMap.set(chunk.facadeModuleId, []);
|
internals.facadeIdToAssetsMap.set(chunk.facadeModuleId, []);
|
||||||
}
|
}
|
||||||
const assets = internals.facadeIdToAssetsMap.get(chunk.facadeModuleId)!;
|
const assets = internals.facadeIdToAssetsMap.get(chunk.facadeModuleId)!;
|
||||||
const assetSet = new Set(assets);
|
const assetSet = new Set(assets);
|
||||||
for(const imp of chunk.imports) {
|
for (const imp of chunk.imports) {
|
||||||
if(internals.chunkToReferenceIdMap.has(imp) && !pureChunkFilenames.has(imp)) {
|
if (internals.chunkToReferenceIdMap.has(imp) && !pureChunkFilenames.has(imp)) {
|
||||||
const referenceId = internals.chunkToReferenceIdMap.get(imp)!;
|
const referenceId = internals.chunkToReferenceIdMap.get(imp)!;
|
||||||
const fileName = this.getFileName(referenceId);
|
const fileName = this.getFileName(referenceId);
|
||||||
if(!assetSet.has(fileName)) {
|
if (!assetSet.has(fileName)) {
|
||||||
assetSet.add(fileName);
|
assetSet.add(fileName);
|
||||||
assets.push(fileName);
|
assets.push(fileName);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +191,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes imports for pure CSS chunks.
|
// Removes imports for pure CSS chunks.
|
||||||
if(hasPureCSSChunks) {
|
if (hasPureCSSChunks) {
|
||||||
if (internals.pureCSSChunks.has(chunk)) {
|
if (internals.pureCSSChunks.has(chunk)) {
|
||||||
// Delete pure CSS chunks, these are JavaScript chunks that only import
|
// Delete pure CSS chunks, these are JavaScript chunks that only import
|
||||||
// other CSS files, so are empty at the end of bundling.
|
// other CSS files, so are empty at the end of bundling.
|
||||||
|
|
|
@ -12,9 +12,7 @@ describe('Static build', () => {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
projectRoot: './fixtures/static-build/',
|
projectRoot: './fixtures/static-build/',
|
||||||
renderers: [
|
renderers: ['@astrojs/renderer-preact'],
|
||||||
'@astrojs/renderer-preact'
|
|
||||||
],
|
|
||||||
buildOptions: {
|
buildOptions: {
|
||||||
experimentalStaticBuild: true,
|
experimentalStaticBuild: true,
|
||||||
},
|
},
|
||||||
|
@ -37,16 +35,16 @@ describe('Static build', () => {
|
||||||
const html = await fixture.readFile(pathname);
|
const html = await fixture.readFile(pathname);
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
const links = $('link[rel=stylesheet]');
|
const links = $('link[rel=stylesheet]');
|
||||||
for(const link of links) {
|
for (const link of links) {
|
||||||
const href = $(link).attr('href');
|
const href = $(link).attr('href');
|
||||||
const data = await fixture.readFile(addLeadingSlash(href));
|
const data = await fixture.readFile(addLeadingSlash(href));
|
||||||
if(expected.test(data)) {
|
if (expected.test(data)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Shared CSS', () => {
|
describe('Shared CSS', () => {
|
||||||
|
|
Loading…
Reference in a new issue