Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alias plugin causing CSS ordering issue #8592

Merged
merged 3 commits into from
Sep 20, 2023
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
5 changes: 5 additions & 0 deletions .changeset/serious-wolves-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix alias plugin causing CSS ordering issue
12 changes: 7 additions & 5 deletions packages/astro/src/vite-plugin-config-alias/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export default function configAliasVitePlugin({

const plugin: VitePlugin = {
name: 'astro:tsconfig-alias',
enforce: 'pre',
// use post to only resolve ids that all other plugins before it can't
enforce: 'post',
configResolved(config) {
patchCreateResolver(config, plugin);
},
Expand Down Expand Up @@ -100,7 +101,7 @@ export default function configAliasVitePlugin({
*
* Vite may simplify this soon: https://github.com/vitejs/vite/pull/10555
*/
function patchCreateResolver(config: ResolvedConfig, prePlugin: VitePlugin) {
function patchCreateResolver(config: ResolvedConfig, postPlugin: VitePlugin) {
const _createResolver = config.createResolver;
// @ts-expect-error override readonly property intentionally
config.createResolver = function (...args1: any) {
Expand All @@ -124,15 +125,16 @@ function patchCreateResolver(config: ResolvedConfig, prePlugin: VitePlugin) {
ssr,
};

const result = await resolver.apply(_createResolver, args2);
if (result) return result;

// @ts-expect-error resolveId exists
const resolved = await prePlugin.resolveId.apply(fakePluginContext, [
const resolved = await postPlugin.resolveId.apply(fakePluginContext, [
id,
importer,
fakeResolveIdOpts,
]);
if (resolved) return resolved;

return resolver.apply(_createResolver, args2);
};
};
}
Expand Down
Loading