Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Aug 5, 2022
1 parent 82a1063 commit 9315ce6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/static-build.ts
Expand Up @@ -7,7 +7,6 @@ import { BuildInternals, createBuildInternals } from '../../core/build/internal.
import { prependForwardSlash } from '../../core/path.js';
import { emptyDir, isModeServerWithNoAdapter, removeDir } from '../../core/util.js';
import { runHookBuildSetup } from '../../integrations/index.js';
import { rollupPluginAstroBuildCSS } from './vite-plugin-css.js';
import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
import type { ViteConfigWithSSR } from '../create-vite';
import { info } from '../logger/core.js';
Expand All @@ -16,6 +15,7 @@ import { trackPageData } from './internal.js';
import type { PageBuildData, StaticBuildOptions } from './types';
import { getTimeStat } from './util.js';
import { vitePluginAnalyzer } from './vite-plugin-analyzer.js';
import { rollupPluginAstroBuildCSS } from './vite-plugin-css.js';
import { vitePluginHoistedScripts } from './vite-plugin-hoisted-scripts.js';
import { vitePluginInternals } from './vite-plugin-internals.js';
import { vitePluginPages } from './vite-plugin-pages.js';
Expand Down
14 changes: 7 additions & 7 deletions packages/astro/src/core/build/vite-plugin-css.ts
@@ -1,16 +1,16 @@
import type { GetModuleInfo, OutputChunk } from 'rollup';
import type { AstroConfig } from '../../@types/astro';
import type { BuildInternals } from './internal';
import type { PageBuildData, StaticBuildOptions } from './types';
import type { AstroConfig } from '../../@types/astro';

import crypto from 'crypto';
import esbuild from 'esbuild';
import npath from 'path';
import { Plugin as VitePlugin } from 'vite';
import { isCSSRequest } from '../render/util.js';
import { relativeToSrcDir } from '../util.js';
import { getTopLevelPages, walkParentInfos } from './graph.js';
import { getPageDataByViteID, getPageDatasByClientOnlyID } from './internal.js';
import { relativeToSrcDir } from '../util.js';
import { isCSSRequest } from '../render/util.js';

interface PluginOptions {
internals: BuildInternals;
Expand All @@ -30,7 +30,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
function nameifyPage(id: string) {
let rel = relativeToSrcDir(astroConfig, id);
// Remove pages, ex. blog/posts/something.astro
if(rel.startsWith('pages/')) {
if (rel.startsWith('pages/')) {
rel = rel.slice(6);
}
// Remove extension, ex. blog/posts/something
Expand All @@ -43,14 +43,14 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]

function createNameForParentPages(id: string, ctx: { getModuleInfo: GetModuleInfo }): string {
const parents = Array.from(getTopLevelPages(id, ctx)).sort();
const proposedName = parents.map(page => nameifyPage(page.id)).join('-');
const proposedName = parents.map((page) => nameifyPage(page.id)).join('-');

// We don't want absurdedly long chunk names, so if this is too long create a hashed version instead.
if(proposedName.length <= MAX_NAME_LENGTH) {
if (proposedName.length <= MAX_NAME_LENGTH) {
return proposedName;
}

const hash = crypto.createHash('sha256');
const hash = crypto.createHash('sha256');
for (const page of parents) {
hash.update(page.id, 'utf-8');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/util.ts
Expand Up @@ -188,7 +188,7 @@ export function isModeServerWithNoAdapter(config: AstroConfig): boolean {

export function relativeToSrcDir(config: AstroConfig, idOrUrl: URL | string) {
let id: string;
if(typeof idOrUrl !== 'string') {
if (typeof idOrUrl !== 'string') {
id = unwrapId(viteID(idOrUrl));
} else {
id = idOrUrl;
Expand Down
1 change: 0 additions & 1 deletion packages/astro/test/glob-pages-css.test.js
Expand Up @@ -17,6 +17,5 @@ describe('Astro.glob on pages/ directory', () => {
let $ = cheerio.load(html);

expect($('link[rel=stylesheet]')).to.have.a.lengthOf(1);

});
});

0 comments on commit 9315ce6

Please sign in to comment.