Home / File/ css-base-path.test.js — astro Source File

css-base-path.test.js — astro Source File

Architecture documentation for css-base-path.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  b8da955d_64be_d008_9e2a_3221c1af60ee["css-base-path.test.js"]
  12269b3f_02d1_3f9c_a4eb_d0e1b999e987["../../../dist/vite-plugin-astro/compile.js"]
  b8da955d_64be_d008_9e2a_3221c1af60ee --> 12269b3f_02d1_3f9c_a4eb_d0e1b999e987
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  b8da955d_64be_d008_9e2a_3221c1af60ee --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  b8da955d_64be_d008_9e2a_3221c1af60ee --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"]
  b8da955d_64be_d008_9e2a_3221c1af60ee --> d9a92db9_c95e_9165_13ac_24b3d859d946
  263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"]
  b8da955d_64be_d008_9e2a_3221c1af60ee --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7
  style b8da955d_64be_d008_9e2a_3221c1af60ee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { pathToFileURL } from 'node:url';
import { resolveConfig } from 'vite';
import { compileAstro } from '../../../dist/vite-plugin-astro/compile.js';

/**
 * Compile Astro source with a given base path
 * @param {string} source - Astro source code
 * @param {string} base - Base path configuration
 */
async function compileWithBase(source, base = '/') {
	const viteConfig = await resolveConfig({ configFile: false }, 'serve');
	const result = await compileAstro({
		compileProps: {
			astroConfig: {
				root: pathToFileURL('/'),
				base,
				experimental: {},
				build: {
					format: 'directory',
				},
				trailingSlash: 'ignore',
			},
			viteConfig,
			preferences: {
				get: () => Promise.resolve(false),
			},
			filename: '/src/pages/index.astro',
			source,
		},
		astroFileToCompileMetadata: new Map(),
		logger: {
			info: () => {},
			warn: () => {},
			error: () => {},
			debug: () => {},
		},
	});
	return result;
}

describe('CSS Base Path Rewriting', () => {
	describe('Absolute URL rewriting', () => {
		it('should rewrite absolute URLs with base path', async () => {
			const source = `
<style>
	@font-face {
		src: url('/fonts/font.woff2');
	}
</style>`;
			const result = await compileWithBase(source, '/my-base/');

			// CSS should be in result.css array
			assert.ok(result.css.length > 0);
			const css = result.css[0].code;

			// URL should be rewritten to include base
			assert.match(css, /url\(['"]?\/my-base\/fonts\/font\.woff2['"]?\)/);
		});
// ... (259 more lines)

Subdomains

Functions

Dependencies

  • ../../../dist/vite-plugin-astro/compile.js
  • node:test
  • node:url
  • strict
  • vite

Frequently Asked Questions

What does css-base-path.test.js do?
css-base-path.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, SsrAdapters subdomain.
What functions are defined in css-base-path.test.js?
css-base-path.test.js defines 1 function(s): compileWithBase.
What does css-base-path.test.js depend on?
css-base-path.test.js imports 5 module(s): ../../../dist/vite-plugin-astro/compile.js, node:test, node:url, strict, vite.
Where is css-base-path.test.js in the architecture?
css-base-path.test.js is located at packages/astro/test/units/compile/css-base-path.test.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test/units/compile).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free