mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
fix(vite): resolve css files without importer id first (#21770)
This commit is contained in:
parent
4cc9a7135d
commit
dd913ce0d8
@ -138,8 +138,8 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin {
|
||||
const s = new MagicString(code)
|
||||
options.clientCSSMap[id] ||= new Set()
|
||||
for (const file of options.globalCSS) {
|
||||
const resolved = await this.resolve(file, id)
|
||||
const res = await this.resolve(file + '?inline&used', id)
|
||||
const resolved = await this.resolve(file) ?? await this.resolve(file, id)
|
||||
const res = await this.resolve(file + '?inline&used') ?? await this.resolve(file + '?inline&used', id)
|
||||
if (!resolved || !res) {
|
||||
if (!warnCache.has(file)) {
|
||||
warnCache.add(file)
|
||||
@ -179,8 +179,9 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin {
|
||||
let styleCtr = 0
|
||||
const ids = options.clientCSSMap[id] || []
|
||||
for (const file of ids) {
|
||||
const resolved = await this.resolve(file, id)
|
||||
if (!resolved || !(await this.resolve(file + '?inline&used', id))) {
|
||||
const resolved = await this.resolve(file) ?? await this.resolve(file, id)
|
||||
const res = await this.resolve(file + '?inline&used') ?? await this.resolve(file + '?inline&used', id)
|
||||
if (!resolved || !res) {
|
||||
if (!warnCache.has(file)) {
|
||||
warnCache.add(file)
|
||||
this.warn(`[nuxt] Cannot extract styles for \`${file}\`. Its styles will not be inlined when server-rendering.`)
|
||||
|
@ -1154,10 +1154,10 @@ describe.skipIf(isDev() || isWebpack)('inlining component styles', () => {
|
||||
'{--global:"global";', // global css from nuxt.config
|
||||
'{--assets:"assets"}', // <script>
|
||||
'{--postcss:"postcss"}', // <style lang=postcss>
|
||||
'{--scoped:"scoped"}' // <style lang=css>
|
||||
'{--scoped:"scoped"}', // <style lang=css>
|
||||
'{--server-only:"server-only"}' // server-only component not in client build
|
||||
// TODO: ideally both client/server components would have inlined css when used
|
||||
// '{--client-only:"client-only"}', // client-only component not in server build
|
||||
// '{--server-only:"server-only"}' // server-only component not in client build
|
||||
// TODO: currently functional component not associated with ssrContext (upstream bug or perf optimization?)
|
||||
// '{--functional:"functional"}', // CSS imported ambiently in a functional component
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user