Fix Svelte and Vue styles in dev (#1933)
This commit is contained in:
parent
684367b7bf
commit
16fa615d34
1 changed files with 19 additions and 9 deletions
|
@ -29,6 +29,8 @@ import { injectTags } from './html.js';
|
||||||
import { generatePaginateFunction } from './paginate.js';
|
import { generatePaginateFunction } from './paginate.js';
|
||||||
import { getParams, validateGetStaticPathsModule, validateGetStaticPathsResult } from './routing.js';
|
import { getParams, validateGetStaticPathsModule, validateGetStaticPathsResult } from './routing.js';
|
||||||
|
|
||||||
|
const svelteAndVueStylesRE = /\?[^&]+&type=style&lang/;
|
||||||
|
|
||||||
interface SSROptions {
|
interface SSROptions {
|
||||||
/** an instance of the AstroConfig */
|
/** an instance of the AstroConfig */
|
||||||
astroConfig: AstroConfig;
|
astroConfig: AstroConfig;
|
||||||
|
@ -245,15 +247,23 @@ export async function render(renderers: Renderer[], mod: ComponentInstance, ssrO
|
||||||
|
|
||||||
// inject CSS
|
// inject CSS
|
||||||
[...getStylesForURL(filePath, viteServer)].forEach((href) => {
|
[...getStylesForURL(filePath, viteServer)].forEach((href) => {
|
||||||
tags.push({
|
if (mode === 'development' && svelteAndVueStylesRE.test(href)) {
|
||||||
tag: 'link',
|
tags.push({
|
||||||
attrs: {
|
tag: 'script',
|
||||||
rel: 'stylesheet',
|
attrs: { type: 'module', src: href },
|
||||||
href,
|
injectTo: 'head',
|
||||||
'data-astro-injected': true,
|
});
|
||||||
},
|
} else {
|
||||||
injectTo: 'head',
|
tags.push({
|
||||||
});
|
tag: 'link',
|
||||||
|
attrs: {
|
||||||
|
rel: 'stylesheet',
|
||||||
|
href,
|
||||||
|
'data-astro-injected': true,
|
||||||
|
},
|
||||||
|
injectTo: 'head',
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// add injected tags
|
// add injected tags
|
||||||
|
|
Loading…
Reference in a new issue