[ci] format
This commit is contained in:
parent
bee8c14afd
commit
591153f457
7 changed files with 33 additions and 27 deletions
|
@ -14,7 +14,6 @@ import type {
|
|||
} from '../../@types/astro';
|
||||
import type { BuildInternals } from '../../core/build/internal.js';
|
||||
import {
|
||||
joinPaths,
|
||||
prependForwardSlash,
|
||||
removeLeadingForwardSlash,
|
||||
removeTrailingForwardSlash,
|
||||
|
@ -292,7 +291,10 @@ async function generatePath(
|
|||
debug('build', `Generating: ${pathname}`);
|
||||
|
||||
const links = createLinkStylesheetElementSet(linkIds, settings.config.base);
|
||||
const scripts = createModuleScriptsSet(hoistedScripts ? [hoistedScripts] : [], settings.config.base);
|
||||
const scripts = createModuleScriptsSet(
|
||||
hoistedScripts ? [hoistedScripts] : [],
|
||||
settings.config.base
|
||||
);
|
||||
|
||||
if (settings.scripts.some((script) => script.stage === 'page')) {
|
||||
const hashedFilePath = internals.entrySpecifierToBundleMap.get(PAGE_SCRIPT_ID);
|
||||
|
|
|
@ -41,7 +41,10 @@ export function vitePluginHoistedScripts(
|
|||
|
||||
async generateBundle(_options, bundle) {
|
||||
let assetInlineLimit = 4096;
|
||||
if(settings.config.vite?.build && settings.config.vite.build.assetsInlineLimit !== undefined) {
|
||||
if (
|
||||
settings.config.vite?.build &&
|
||||
settings.config.vite.build.assetsInlineLimit !== undefined
|
||||
) {
|
||||
assetInlineLimit = settings.config.vite?.build.assetsInlineLimit;
|
||||
}
|
||||
|
||||
|
|
|
@ -139,15 +139,16 @@ function buildManifest(
|
|||
for (const pageData of eachPageData(internals)) {
|
||||
const scripts: SerializedRouteInfo['scripts'] = [];
|
||||
if (pageData.hoistedScript) {
|
||||
scripts.unshift(Object.assign({}, pageData.hoistedScript, {
|
||||
value: joinBase(pageData.hoistedScript.value)
|
||||
}));
|
||||
scripts.unshift(
|
||||
Object.assign({}, pageData.hoistedScript, {
|
||||
value: joinBase(pageData.hoistedScript.value),
|
||||
})
|
||||
);
|
||||
}
|
||||
if (settings.scripts.some((script) => script.stage === 'page')) {
|
||||
scripts.push({ type: 'external', value: entryModules[PAGE_SCRIPT_ID] });
|
||||
}
|
||||
|
||||
|
||||
const links = sortedCSS(pageData).map((pth) => joinBase(pth));
|
||||
|
||||
routes.push({
|
||||
|
|
|
@ -326,19 +326,19 @@ export function createRelativeSchema(cmd: string, fileProtocolRoot: URL) {
|
|||
|
||||
// If there is no base but there is a base for site config, warn.
|
||||
const sitePathname = config.site && new URL(config.site).pathname;
|
||||
if(!trimmedBase.length && sitePathname && sitePathname !== '/') {
|
||||
if (!trimmedBase.length && sitePathname && sitePathname !== '/') {
|
||||
config.base = sitePathname;
|
||||
/* eslint-disable no-console */
|
||||
console.warn(`The site configuration value includes a pathname of ${sitePathname} but there is no base configuration.
|
||||
|
||||
A future version of Astro will stop using the site pathname when producing <link> and <script> tags. Set your site's base with the base configuration.`)
|
||||
A future version of Astro will stop using the site pathname when producing <link> and <script> tags. Set your site's base with the base configuration.`);
|
||||
}
|
||||
|
||||
if(trimmedBase.length && config.trailingSlash === 'never') {
|
||||
config.base = prependForwardSlash(trimmedBase);
|
||||
} else {
|
||||
config.base = prependForwardSlash(appendForwardSlash(trimmedBase));
|
||||
}
|
||||
if (trimmedBase.length && config.trailingSlash === 'never') {
|
||||
config.base = prependForwardSlash(trimmedBase);
|
||||
} else {
|
||||
config.base = prependForwardSlash(appendForwardSlash(trimmedBase));
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
|
|
|
@ -11,12 +11,12 @@ describe('Asset URL resolution in build', () => {
|
|||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/asset-url-base/',
|
||||
site: 'http://example.com/sub/path/'
|
||||
site: 'http://example.com/sub/path/',
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
||||
it('does not include the site\'s subpath', async () => {
|
||||
|
||||
it("does not include the site's subpath", async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
const href = $('link[rel=stylesheet]').attr('href');
|
||||
|
@ -29,12 +29,12 @@ describe('Asset URL resolution in build', () => {
|
|||
fixture = await loadFixture({
|
||||
root: './fixtures/asset-url-base/',
|
||||
site: 'http://example.com/sub/path/',
|
||||
base: '/another/base/'
|
||||
base: '/another/base/',
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
||||
it('does not include the site\'s subpath', async () => {
|
||||
|
||||
it("does not include the site's subpath", async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
const href = $('link[rel=stylesheet]').attr('href');
|
||||
|
|
|
@ -116,18 +116,18 @@ describe('Scripts (hoisted and not)', () => {
|
|||
it('External page builds the hoisted scripts to a single bundle', async () => {
|
||||
let external = await fixture.readFile('/external/index.html');
|
||||
let $ = cheerio.load(external);
|
||||
|
||||
|
||||
// test 1: there are two scripts
|
||||
expect($('script')).to.have.lengthOf(2);
|
||||
|
||||
|
||||
let el = $('script').get(1);
|
||||
expect($(el).attr('src')).to.equal(undefined, 'This should have been inlined');
|
||||
let externalEntryJS = $(el).text();
|
||||
|
||||
|
||||
// test 2: the JS exists
|
||||
expect(externalEntryJS).to.be.ok;
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dev', () => {
|
||||
|
|
|
@ -15,9 +15,9 @@ describe('Using Astro.request in SSR', () => {
|
|||
base: '/subpath/',
|
||||
vite: {
|
||||
build: {
|
||||
assetsInlineLimit: 0
|
||||
}
|
||||
}
|
||||
assetsInlineLimit: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue