Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/astro/src/vite-plugin-css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const ASTRO_CSS_EXTENSION_POST_PATTERN = '@_@';
* Inverse function of getVirtualModulePageName().
*/
function getComponentFromVirtualModuleCssName(virtualModulePrefix: string, id: string): string {
return id.slice(virtualModulePrefix.length).replace(new RegExp(ASTRO_CSS_EXTENSION_POST_PATTERN, 'g'), '.');
return id
.slice(virtualModulePrefix.length)
.replace(new RegExp(ASTRO_CSS_EXTENSION_POST_PATTERN, 'g'), '.');
}

/**
Expand Down Expand Up @@ -56,7 +58,10 @@ export function astroDevCssPlugin({ routesList, command }: AstroVitePluginOption
};
}
if (id.startsWith(RESOLVED_MODULE_DEV_CSS_PREFIX)) {
const componentPath = getComponentFromVirtualModuleCssName(RESOLVED_MODULE_DEV_CSS_PREFIX, id);
const componentPath = getComponentFromVirtualModuleCssName(
RESOLVED_MODULE_DEV_CSS_PREFIX,
id,
);
const cssSet = routeCssMap.get(componentPath) || new Set<ImportedDevStyle>();
return {
code: `export const css = new Set(${JSON.stringify(Array.from(cssSet.values()))})`,
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/vite-plugin-pages/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extname } from 'node:path';
import { fileExtension } from '@astrojs/internal-helpers/path';

// This is an arbitrary string that we use to replace the dot of the extension.
const ASTRO_PAGE_EXTENSION_POST_PATTERN = '@_@';
Expand All @@ -10,7 +10,7 @@ const ASTRO_PAGE_EXTENSION_POST_PATTERN = '@_@';
* @param path Page component path
*/
export function getVirtualModulePageName(virtualModulePrefix: string, path: string): string {
const extension = extname(path);
const extension = fileExtension(path);
return (
virtualModulePrefix +
(extension.startsWith('.')
Expand Down
Loading