summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Drew Powers <1369770+drwpow@users.noreply.github.com> 2021-11-19 13:53:44 -0700
committerGravatar GitHub <noreply@github.com> 2021-11-19 13:53:44 -0700
commit16fa615d34b1e3932b74c19af142c4b7344b0a68 (patch)
tree42c70d882725e429faee29e6be25bf38a0ce9483
parent684367b7bf25b39eb044d7e97367b1283f72e8d2 (diff)
downloadastro-16fa615d34b1e3932b74c19af142c4b7344b0a68.tar.gz
astro-16fa615d34b1e3932b74c19af142c4b7344b0a68.tar.zst
astro-16fa615d34b1e3932b74c19af142c4b7344b0a68.zip
Fix Svelte and Vue styles in dev (#1933)
-rw-r--r--packages/astro/src/core/ssr/index.ts28
1 files changed, 19 insertions, 9 deletions
diff --git a/packages/astro/src/core/ssr/index.ts b/packages/astro/src/core/ssr/index.ts
index 07bab9f13..7974a515e 100644
--- a/packages/astro/src/core/ssr/index.ts
+++ b/packages/astro/src/core/ssr/index.ts
@@ -29,6 +29,8 @@ import { injectTags } from './html.js';
import { generatePaginateFunction } from './paginate.js';
import { getParams, validateGetStaticPathsModule, validateGetStaticPathsResult } from './routing.js';
+const svelteAndVueStylesRE = /\?[^&]+&type=style&lang/;
+
interface SSROptions {
/** an instance of the AstroConfig */
astroConfig: AstroConfig;
@@ -245,15 +247,23 @@ export async function render(renderers: Renderer[], mod: ComponentInstance, ssrO
// inject CSS
[...getStylesForURL(filePath, viteServer)].forEach((href) => {
- tags.push({
- tag: 'link',
- attrs: {
- rel: 'stylesheet',
- href,
- 'data-astro-injected': true,
- },
- injectTo: 'head',
- });
+ if (mode === 'development' && svelteAndVueStylesRE.test(href)) {
+ tags.push({
+ tag: 'script',
+ attrs: { type: 'module', src: href },
+ injectTo: 'head',
+ });
+ } else {
+ tags.push({
+ tag: 'link',
+ attrs: {
+ rel: 'stylesheet',
+ href,
+ 'data-astro-injected': true,
+ },
+ injectTo: 'head',
+ });
+ }
});
// add injected tags