aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar matthewp <matthewp@users.noreply.github.com> 2022-01-12 17:04:04 +0000
committerGravatar GitHub Actions <actions@github.com> 2022-01-12 17:04:04 +0000
commitbabed028768a5abbc616c1426ca357e5b6a795be (patch)
tree86f950bb5e1c5b84066e83366a7181275647ecf9
parent20d0cce681d5e913ca19c2466055f69541bced23 (diff)
downloadastro-babed028768a5abbc616c1426ca357e5b6a795be.tar.gz
astro-babed028768a5abbc616c1426ca357e5b6a795be.tar.zst
astro-babed028768a5abbc616c1426ca357e5b6a795be.zip
[ci] yarn format
-rw-r--r--packages/astro/src/vite-plugin-build-css/index.ts22
-rw-r--r--packages/astro/test/static-build.test.js10
2 files changed, 16 insertions, 16 deletions
diff --git a/packages/astro/src/vite-plugin-build-css/index.ts b/packages/astro/src/vite-plugin-build-css/index.ts
index 5a4d4be20..0a1757842 100644
--- a/packages/astro/src/vite-plugin-build-css/index.ts
+++ b/packages/astro/src/vite-plugin-build-css/index.ts
@@ -13,7 +13,11 @@ const ASTRO_STYLE_PREFIX = '@astro-inline-style';
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);
export function getAstroPageStyleId(pathname: string) {
@@ -110,8 +114,6 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
return null;
},
-
-
async renderChunk(_code, chunk) {
let chunkCSS = '';
let isPureCSS = true;
@@ -143,7 +145,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
internals.chunkToReferenceIdMap.set(chunk.fileName, referenceId);
if (chunk.type === 'chunk') {
const fileName = this.getFileName(referenceId);
- if(chunk.facadeModuleId) {
+ if (chunk.facadeModuleId) {
const facadeId = chunk.facadeModuleId!;
if (!internals.facadeIdToAssetsMap.has(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.
// This find shared chunks of CSS and adds them to the main CSS chunks,
// so that shared CSS is added to the page.
- if(chunk.facadeModuleId) {
- if(!internals.facadeIdToAssetsMap.has(chunk.facadeModuleId)) {
+ if (chunk.facadeModuleId) {
+ if (!internals.facadeIdToAssetsMap.has(chunk.facadeModuleId)) {
internals.facadeIdToAssetsMap.set(chunk.facadeModuleId, []);
}
const assets = internals.facadeIdToAssetsMap.get(chunk.facadeModuleId)!;
const assetSet = new Set(assets);
- for(const imp of chunk.imports) {
- if(internals.chunkToReferenceIdMap.has(imp) && !pureChunkFilenames.has(imp)) {
+ for (const imp of chunk.imports) {
+ if (internals.chunkToReferenceIdMap.has(imp) && !pureChunkFilenames.has(imp)) {
const referenceId = internals.chunkToReferenceIdMap.get(imp)!;
const fileName = this.getFileName(referenceId);
- if(!assetSet.has(fileName)) {
+ if (!assetSet.has(fileName)) {
assetSet.add(fileName);
assets.push(fileName);
}
@@ -189,7 +191,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
}
// Removes imports for pure CSS chunks.
- if(hasPureCSSChunks) {
+ if (hasPureCSSChunks) {
if (internals.pureCSSChunks.has(chunk)) {
// Delete pure CSS chunks, these are JavaScript chunks that only import
// other CSS files, so are empty at the end of bundling.
diff --git a/packages/astro/test/static-build.test.js b/packages/astro/test/static-build.test.js
index a8a12ddae..7e93706cf 100644
--- a/packages/astro/test/static-build.test.js
+++ b/packages/astro/test/static-build.test.js
@@ -12,9 +12,7 @@ describe('Static build', () => {
before(async () => {
fixture = await loadFixture({
projectRoot: './fixtures/static-build/',
- renderers: [
- '@astrojs/renderer-preact'
- ],
+ renderers: ['@astrojs/renderer-preact'],
buildOptions: {
experimentalStaticBuild: true,
},
@@ -37,16 +35,16 @@ describe('Static build', () => {
const html = await fixture.readFile(pathname);
const $ = cheerio.load(html);
const links = $('link[rel=stylesheet]');
- for(const link of links) {
+ for (const link of links) {
const href = $(link).attr('href');
const data = await fixture.readFile(addLeadingSlash(href));
- if(expected.test(data)) {
+ if (expected.test(data)) {
return true;
}
}
return false;
- }
+ };
}
describe('Shared CSS', () => {