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

Commit

Permalink
feat(vite): add warning when styles cannot be extracted
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Sep 12, 2022
1 parent f928cfb commit d726328
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/vite/src/plugins/ssr-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin {

const relativeToSrcDir = (path: string) => relative(options.srcDir, path)

const warnCache = new Set<string>()

return {
name: 'ssr-styles',
generateBundle (outputOptions) {
Expand Down Expand Up @@ -104,7 +106,13 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin {

const resolved = await this.resolve(i.specifier, id)
if (!resolved) { continue }
if (!(await this.resolve(resolved.id + '?inline&used'))) { continue }
if (!(await this.resolve(resolved.id + '?inline&used'))) {
if (!warnCache.has(resolved.id)) {
warnCache.add(resolved.id)
this.warn(`[nuxt] Cannot extract styles for \`${i.specifier}\`. Its styles will not be inlined when server-rendering.`)
}
continue
}

const ref = this.emitFile({
type: 'chunk',
Expand Down

0 comments on commit d726328

Please sign in to comment.