mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(nuxt): always inline entry styles (#7386)
This commit is contained in:
parent
e60d03b940
commit
83949c3734
@ -224,7 +224,7 @@ function renderHTMLDocument (html: NuxtRenderHTMLContext) {
|
|||||||
async function renderInlineStyles (usedModules: Set<string> | string[]) {
|
async function renderInlineStyles (usedModules: Set<string> | string[]) {
|
||||||
const styleMap = await getSSRStyles()
|
const styleMap = await getSSRStyles()
|
||||||
const inlinedStyles = new Set<string>()
|
const inlinedStyles = new Set<string>()
|
||||||
for (const mod of usedModules) {
|
for (const mod of ['entry', ...usedModules]) {
|
||||||
if (mod in styleMap) {
|
if (mod in styleMap) {
|
||||||
for (const style of await styleMap[mod]()) {
|
for (const style of await styleMap[mod]()) {
|
||||||
inlinedStyles.add(`<style>${style}</style>`)
|
inlinedStyles.add(`<style>${style}</style>`)
|
||||||
|
@ -60,11 +60,11 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin {
|
|||||||
source:
|
source:
|
||||||
[
|
[
|
||||||
...globalStylesArray.map((css, i) => `import style_${i} from './${css}';`),
|
...globalStylesArray.map((css, i) => `import style_${i} from './${css}';`),
|
||||||
`const globalStyles = [${globalStylesArray.map((_, i) => `style_${i}`).join(', ')}]`,
|
'const interopDefault = r => r.default || r || []',
|
||||||
'const resolveStyles = r => globalStyles.concat(r.default || r || [])',
|
`export default ${genObjectFromRawEntries([
|
||||||
`export default ${genObjectFromRawEntries(
|
['entry', `() => [${globalStylesArray.map((_, i) => `style_${i}`).join(', ')}]`],
|
||||||
Object.entries(emitted).map(([key, value]) => [key, `() => import('./${this.getFileName(value)}').then(resolveStyles)`])
|
...Object.entries(emitted).map(([key, value]) => [key, `() => import('./${this.getFileName(value)}').then(interopDefault)`]) as [string, string][]
|
||||||
)}`
|
])}`
|
||||||
].join('\n')
|
].join('\n')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user