[ci] format
This commit is contained in:
parent
b3d936ac24
commit
edfbb0c9dd
3 changed files with 27 additions and 25 deletions
|
@ -2,9 +2,9 @@ import type { GetModuleInfo } from 'rollup';
|
|||
|
||||
import crypto from 'crypto';
|
||||
import npath from 'path';
|
||||
import { getTopLevelPages } from './graph.js';
|
||||
import { AstroSettings } from '../../@types/astro';
|
||||
import { viteID } from '../util.js';
|
||||
import { getTopLevelPages } from './graph.js';
|
||||
|
||||
// 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
|
||||
|
@ -45,7 +45,7 @@ export function createSlugger(settings: AstroSettings) {
|
|||
}
|
||||
|
||||
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);
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import esbuild from 'esbuild';
|
|||
import { Plugin as VitePlugin, ResolvedConfig } from 'vite';
|
||||
import { isCSSRequest } from '../render/util.js';
|
||||
|
||||
import * as assetName from './css-asset-name.js';
|
||||
import { moduleIsTopLevelPage, walkParentInfos } from './graph.js';
|
||||
import {
|
||||
eachPageData,
|
||||
|
@ -14,7 +15,6 @@ import {
|
|||
getPageDatasByHoistedScriptId,
|
||||
isHoistedScript,
|
||||
} from './internal.js';
|
||||
import * as assetName from './css-asset-name.js';
|
||||
|
||||
interface PluginOptions {
|
||||
internals: BuildInternals;
|
||||
|
@ -45,7 +45,9 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
|
|||
const manualChunks = outputOptions.manualChunks || Function.prototype;
|
||||
const assetFileNames = outputOptions.assetFileNames;
|
||||
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) {
|
||||
// Defer to user-provided `manualChunks`, if it was provided.
|
||||
if (typeof manualChunks == 'object') {
|
||||
|
|
|
@ -80,12 +80,12 @@ describe('CSS Bundling', function () {
|
|||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
assetFileNames: "assets/[name][extname]",
|
||||
entryFileNames: "[name].js",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assetFileNames: 'assets/[name][extname]',
|
||||
entryFileNames: '[name].js',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
await fixture.build({ mode: 'production' });
|
||||
});
|
||||
|
@ -102,7 +102,7 @@ describe('CSS Bundling', function () {
|
|||
|
||||
it('there are 2 index named CSS files', async () => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue