Fix alias plugin causing CSS ordering issue (#8592)
This commit is contained in:
parent
c49e865f4f
commit
70f2a80039
2 changed files with 12 additions and 5 deletions
5
.changeset/serious-wolves-breathe.md
Normal file
5
.changeset/serious-wolves-breathe.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix alias plugin causing CSS ordering issue
|
|
@ -70,7 +70,8 @@ export default function configAliasVitePlugin({
|
||||||
|
|
||||||
const plugin: VitePlugin = {
|
const plugin: VitePlugin = {
|
||||||
name: 'astro:tsconfig-alias',
|
name: 'astro:tsconfig-alias',
|
||||||
enforce: 'pre',
|
// use post to only resolve ids that all other plugins before it can't
|
||||||
|
enforce: 'post',
|
||||||
configResolved(config) {
|
configResolved(config) {
|
||||||
patchCreateResolver(config, plugin);
|
patchCreateResolver(config, plugin);
|
||||||
},
|
},
|
||||||
|
@ -100,7 +101,7 @@ export default function configAliasVitePlugin({
|
||||||
*
|
*
|
||||||
* Vite may simplify this soon: https://github.com/vitejs/vite/pull/10555
|
* 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;
|
const _createResolver = config.createResolver;
|
||||||
// @ts-expect-error override readonly property intentionally
|
// @ts-expect-error override readonly property intentionally
|
||||||
config.createResolver = function (...args1: any) {
|
config.createResolver = function (...args1: any) {
|
||||||
|
@ -124,15 +125,16 @@ function patchCreateResolver(config: ResolvedConfig, prePlugin: VitePlugin) {
|
||||||
ssr,
|
ssr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const result = await resolver.apply(_createResolver, args2);
|
||||||
|
if (result) return result;
|
||||||
|
|
||||||
// @ts-expect-error resolveId exists
|
// @ts-expect-error resolveId exists
|
||||||
const resolved = await prePlugin.resolveId.apply(fakePluginContext, [
|
const resolved = await postPlugin.resolveId.apply(fakePluginContext, [
|
||||||
id,
|
id,
|
||||||
importer,
|
importer,
|
||||||
fakeResolveIdOpts,
|
fakeResolveIdOpts,
|
||||||
]);
|
]);
|
||||||
if (resolved) return resolved;
|
if (resolved) return resolved;
|
||||||
|
|
||||||
return resolver.apply(_createResolver, args2);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue