Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/nitro-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 18, 2022
2 parents b429283 + e0d6812 commit 0439a8a
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .stackblitz/config.json
@@ -0,0 +1,3 @@
{
"startCommand": "pnpm build:stub && pnpm play"
}
1 change: 1 addition & 0 deletions docs/content/1.getting-started/10.deployment.md
Expand Up @@ -139,6 +139,7 @@ Nuxt 3 can be deployed to several cloud providers with a minimal amount of confi

- :IconCloud{class="h-5 w-4 inline mb-2"} [AWS](https://nitro.unjs.io/deploy/providers/aws)
- :LogoAzure{class="h-5 w-4 inline mb-2"} [Azure](https://nitro.unjs.io/deploy/providers/azure)
- :IconCloud{class="h-5 w-4 inline mb-2"} [Cleavr](https://nitro.unjs.io/deploy/providers/cleavr)
- :LogoCloudFlare{class="h-5 w-4 inline mb-2"} [CloudFlare](https://nitro.unjs.io/deploy/providers/cloudflare)
- :IconCloud{class="h-5 w-4 inline mb-2"} [Digital Ocean](https://nitro.unjs.io/deploy/providers/digitalocean)
- :LogoFirebase{class="h-5 w-4 inline mb-2"} [Firebase](https://nitro.unjs.io/deploy/providers/firebase)
Expand Down
1 change: 1 addition & 0 deletions docs/public/_redirects
Expand Up @@ -74,4 +74,5 @@
/guide/deploy/providers/render https://nitro.unjs.io/deploy/providers/render 302!
/guide/deploy/providers/stormkit https://nitro.unjs.io/deploy/providers/stormkit 302!
/guide/deploy/providers/vercel https://nitro.unjs.io/deploy/providers/vercel 302!
/guide/deploy/providers/cleavr https://nitro.unjs.io/deploy/providers/cleavr 302!

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -51,7 +51,7 @@
"@types/node": "^16.11.66",
"@types/rimraf": "^3",
"@types/semver": "^7",
"@unocss/reset": "^0.45.29",
"@unocss/reset": "^0.45.30",
"case-police": "^0.5.10",
"changelogen": "^0.3.5",
"crawler": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/package.json
Expand Up @@ -35,7 +35,7 @@
"execa": "^6.1.0",
"flat": "^5.0.2",
"giget": "^0.1.7",
"h3": "^0.8.3",
"h3": "^0.8.4",
"jiti": "^1.16.0",
"listhen": "^0.3.4",
"mlly": "^0.5.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/package.json
Expand Up @@ -52,7 +52,7 @@
"escape-string-regexp": "^5.0.0",
"fs-extra": "^10.1.0",
"globby": "^13.1.2",
"h3": "^0.8.3",
"h3": "^0.8.4",
"hash-sum": "^2.0.0",
"hookable": "^5.4.1",
"knitwork": "^0.1.2",
Expand Down
13 changes: 11 additions & 2 deletions packages/nuxt/src/core/runtime/nitro/renderer.ts
Expand Up @@ -10,7 +10,12 @@ import { useRuntimeConfig, useNitroApp, defineRenderHandler, getRouteRules } fro
import type { NuxtApp, NuxtSSRContext } from '#app'

// @ts-ignore
import { buildAssetsURL } from '#paths'
import { buildAssetsURL, publicAssetsURL } from '#paths'

// @ts-ignore
globalThis.__buildAssetsURL = buildAssetsURL
// @ts-ignore
globalThis.__publicAssetsURL = publicAssetsURL

export interface NuxtRenderHTMLContext {
htmlAttrs: string[]
Expand Down Expand Up @@ -198,7 +203,7 @@ export default defineRenderHandler(async (event) => {
const renderedMeta = await ssrContext.renderMeta?.() ?? {}

// Render inline styles
const inlinedStyles = process.env.NUXT_INLINE_STYLES && !(process.env.NUXT_NO_SSR || ssrContext.noSSR)
const inlinedStyles = process.env.NUXT_INLINE_STYLES
? await renderInlineStyles(ssrContext.modules ?? ssrContext._registeredComponents ?? [])
: ''

Expand Down Expand Up @@ -284,6 +289,7 @@ function renderHTMLDocument (html: NuxtRenderHTMLContext) {
}

async function renderInlineStyles (usedModules: Set<string> | string[]) {
const { entryCSS } = await getClientManifest()
const styleMap = await getSSRStyles()
const inlinedStyles = new Set<string>()
for (const mod of ['entry', ...usedModules]) {
Expand All @@ -293,6 +299,9 @@ async function renderInlineStyles (usedModules: Set<string> | string[]) {
}
}
}
for (const css of entryCSS?.css || []) {
inlinedStyles.add(`<link rel="stylesheet" href=${JSON.stringify(buildAssetsURL(css))} media="print" onload="this.media='all'; this.onload=null;">`)
}
return Array.from(inlinedStyles).join('')
}

Expand Down
7 changes: 5 additions & 2 deletions packages/nuxt/src/core/templates.ts
Expand Up @@ -240,8 +240,11 @@ export const publicPathTemplate: NuxtTemplate = {
' return path.length ? joinURL(publicBase, ...path) : publicBase',
'}',

'globalThis.__buildAssetsURL = buildAssetsURL',
'globalThis.__publicAssetsURL = publicAssetsURL'
// On server these are registered directly in packages/nuxt/src/core/runtime/nitro/renderer.ts
'if (process.client) {',
' globalThis.__buildAssetsURL = buildAssetsURL',
' globalThis.__publicAssetsURL = publicAssetsURL',
'}'
].filter(Boolean).join('\n')
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Expand Up @@ -33,7 +33,7 @@
"externality": "^0.2.2",
"fs-extra": "^10.1.0",
"get-port-please": "^2.6.1",
"h3": "^0.8.3",
"h3": "^0.8.4",
"knitwork": "^0.1.2",
"magic-string": "^0.26.7",
"mlly": "^0.5.16",
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/server.ts
Expand Up @@ -129,13 +129,13 @@ export async function buildServer (ctx: ViteBuildContext) {
}
// Add entry CSS as prefetch (non-blocking)
if (entry.isEntry) {
manifest[key + '-css'] = {
manifest.entryCSS = {
file: '',
css: entry.css
}
entry.css = []
entry.dynamicImports = entry.dynamicImports || []
entry.dynamicImports.push(key + '-css')
entry.dynamicImports.push('entryCSS')
}
}
})
Expand Down
28 changes: 12 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions test/basic.test.ts
Expand Up @@ -616,8 +616,7 @@ describe.skipIf(process.env.NUXT_TEST_DEV || process.env.TEST_WITH_WEBPACK)('inl
`)
})

// TODO: fix this in style inlining implementation: https://github.com/nuxt/framework/pull/8265#issuecomment-1282148407
it.skip('still downloads client-only styles', async () => {
it('still downloads client-only styles', async () => {
const page = await createPage('/styles')
await page.waitForLoadState('networkidle')
expect(await page.$eval('.client-only-css', e => getComputedStyle(e).color)).toBe('rgb(50, 50, 50)')
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0439a8a

Please sign in to comment.