[ci] format

This commit is contained in:
matthewp 2022-11-10 22:14:23 +00:00 committed by fredkbot
parent b3d936ac24
commit edfbb0c9dd
3 changed files with 27 additions and 25 deletions

View file

@ -2,9 +2,9 @@ import type { GetModuleInfo } from 'rollup';
import crypto from 'crypto'; import crypto from 'crypto';
import npath from 'path'; import npath from 'path';
import { getTopLevelPages } from './graph.js';
import { AstroSettings } from '../../@types/astro'; import { AstroSettings } from '../../@types/astro';
import { viteID } from '../util.js'; import { viteID } from '../util.js';
import { getTopLevelPages } from './graph.js';
// The short name for when the hash can be included // The short name for when the hash can be included
// We could get rid of this and only use the createSlugger implementation, but this creates // We could get rid of this and only use the createSlugger implementation, but this creates
@ -45,7 +45,7 @@ export function createSlugger(settings: AstroSettings) {
} }
const name = npath.parse(npath.basename(dir)).name; const name = npath.parse(npath.basename(dir)).name;
key = key.length ? (name + sep + key) : name; key = key.length ? name + sep + key : name;
dir = npath.dirname(dir); dir = npath.dirname(dir);
i++; i++;
} }

View file

@ -6,6 +6,7 @@ import esbuild from 'esbuild';
import { Plugin as VitePlugin, ResolvedConfig } from 'vite'; import { Plugin as VitePlugin, ResolvedConfig } from 'vite';
import { isCSSRequest } from '../render/util.js'; import { isCSSRequest } from '../render/util.js';
import * as assetName from './css-asset-name.js';
import { moduleIsTopLevelPage, walkParentInfos } from './graph.js'; import { moduleIsTopLevelPage, walkParentInfos } from './graph.js';
import { import {
eachPageData, eachPageData,
@ -14,7 +15,6 @@ import {
getPageDatasByHoistedScriptId, getPageDatasByHoistedScriptId,
isHoistedScript, isHoistedScript,
} from './internal.js'; } from './internal.js';
import * as assetName from './css-asset-name.js';
interface PluginOptions { interface PluginOptions {
internals: BuildInternals; internals: BuildInternals;
@ -45,7 +45,9 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
const manualChunks = outputOptions.manualChunks || Function.prototype; const manualChunks = outputOptions.manualChunks || Function.prototype;
const assetFileNames = outputOptions.assetFileNames; const assetFileNames = outputOptions.assetFileNames;
const namingIncludesHash = assetFileNames?.toString().includes('[hash]'); const namingIncludesHash = assetFileNames?.toString().includes('[hash]');
const createNameForParentPages = namingIncludesHash ? assetName.shortHashedName : assetName.createSlugger(settings); const createNameForParentPages = namingIncludesHash
? assetName.shortHashedName
: assetName.createSlugger(settings);
outputOptions.manualChunks = function (id, ...args) { outputOptions.manualChunks = function (id, ...args) {
// Defer to user-provided `manualChunks`, if it was provided. // Defer to user-provided `manualChunks`, if it was provided.
if (typeof manualChunks == 'object') { if (typeof manualChunks == 'object') {

View file

@ -80,12 +80,12 @@ describe('CSS Bundling', function () {
build: { build: {
rollupOptions: { rollupOptions: {
output: { output: {
assetFileNames: "assets/[name][extname]", assetFileNames: 'assets/[name][extname]',
entryFileNames: "[name].js", entryFileNames: '[name].js',
} },
} },
} },
} },
}); });
await fixture.build({ mode: 'production' }); await fixture.build({ mode: 'production' });
}); });
@ -102,7 +102,7 @@ describe('CSS Bundling', function () {
it('there are 2 index named CSS files', async () => { it('there are 2 index named CSS files', async () => {
const dir = await fixture.readdir('/assets'); const dir = await fixture.readdir('/assets');
const indexNamedFiles = dir.filter(name => name.startsWith('index')) const indexNamedFiles = dir.filter((name) => name.startsWith('index'));
expect(indexNamedFiles).to.have.a.lengthOf(2); expect(indexNamedFiles).to.have.a.lengthOf(2);
}); });
}); });