Skip to content

Spaces in path to configFile break build #396

Open

Description

@avandijk-wur

vuetify-nuxt-module version

1.0.0-rc.6

Nuxt version

4.5.2

Vuetify version

3.13.4

Reproduction

Steps to reproduce

  1. Create a Nuxt project on a Windows environment on a path that contains a space, e.g. E:/Jenkins/workspace/pull request build
  2. Add sass-embedded
  3. Add the vuetify-nuxt-module
  4. Create a file 'styles/settings.scss' with the following contents:
@use 'vuetify/settings' with(    
    $body-font-family: 'Comic Sans MS'
)
  1. Define a Nuxt configuration with a configFile, e.g.:
export default defineNuxtConfig({
  css: [resolve('styles/ui.scss')],
  imports: {
    dirs: [resolve('composables/**'), resolve('stores/**'), resolve('utils/**')],
  },
  modules: ['vuetify-nuxt-module'],
  vuetify: {
    moduleOptions: {
      prefixComposables: ['useLayout'], // Prevent conflict with Nuxt useLayout, See https://github.com/vuetifyjs/cli/issues/25
      styles: {
        configFile: 'styles/settings.scss',
      },
    },
  },
})
  1. Run npx nuxt generate

Expected behavior

nuxt generate should succeed

Actual behavior

nuxt generate exits with the following error:

 [plugin vite:css] virtual:nuxt:node_modules%2F.cache%2Fnuxt%2F.nuxt%2Fvuetify%2Fvuetify.settings.scss
│  Error: [sass] Error: Can't find stylesheet to import.
│    ╷
│  1 │ @use 'E:/Jenkins/workspace/pull request build/styles/settings.scss';

System info

Operating system Windows 10.0.26200
CPU AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics (16 cores)
Node.js version v26.8.1
nuxt/cli version 3.37.0
Package manager npm@11.19.0
Nuxt version 4.5.2
Nitro version 2.13.4
Builder vite@8.3.1
Config app, compatibilityDate, components, devServer, devtools, modules, srcDir, ssr, typescript, vite
Modules @nuxt/eslint@1.17.0

Additional context

No response

Validations

  • I have searched the existing issues and this is not a duplicate.
  • I have provided a minimal reproduction.
  • I have read the documentation.

Activity

  1. userquin commented on Sep 25, 2026

    @userquin
    Member

    The bug at @vuetify/unplugin-styles (@AndreyYolkin still private?)

  2. userquin commented on Sep 25, 2026

    @userquin
    Member

    We need to add a test for this (at unplugin-styles) and check if it works on a non Windows OS (SASS/SCSS)

  3. haigou-web commented on Oct 5, 2026

    @haigou-web

    vuetifyjs/nuxt-module #396 — Root cause diagnosis

    TL;DR

    The bug is not caused by the space in the path. It reproduces on any Windows path.

    styles.configFile is interpolated into an @use rule as a bare Windows path (C:/...).
    Dart Sass parses C: as a URL scheme, so the import fails — the space is irrelevant.

    The two consumers of the same variable behave differently, which is why this only shows up on
    one code path.

    Evidence 1 — bare drive-letter paths never resolve

    Run with sass-embedded on Windows:

    npx sass --stdin --load-path=. --no-source-map
    @use URL Result
    "file:///C:/pirepro/nospace/styles/settings.scss" ✅ compiles
    "file:///C:/pirepro/real/proj%20with%20space/styles/settings.scss" ✅ compiles
    "C:/pirepro/nospace/styles/settings.scss" ❌ Error: Can't find stylesheet to import.
    "C:/pirepro/real/proj with space/styles/settings.scss" ❌ Error: Can't find stylesheet to import.

    A bare C:/... fails with and without a space. A file:// URL works with and without a space.

    This is why the maintainer's suggestion to check a non-Windows OS is the right instinct: on
    Linux/macOS resolvePath() returns /home/user/project/styles/settings.scss, and a leading /
    is understood by Sass as a filesystem-absolute path. On Windows the leading C: is read as a
    scheme instead.

    Evidence 2 — the module interpolates the path without converting it

    vuetify-nuxt-module@1.0.0-rc.6, dist/module.mjs:

    // L205-206
    function getTemplate(source, settings) {
      return [settings ? `@use '${settings}';` : "", `@use '${source}';`].filter(Boolean).join("\n");
    }
    // L220-231
    if (typeof styles === "object" && "configFile" in styles) {
      const configFile = resolveVuetifyConfigFile(styles.configFile, nuxt);
      ctx.stylesConfigFile = await resolvePath(configFile);   // -> C:/... on Windows
      const a = addTemplate({
        write: true,
        filename: "vuetify/vuetify.settings.scss",
        getContents: async () => getTemplate("vuetify/styles", ctx.stylesConfigFile)   // <- bare path
      });
      nuxt.options.css.push(a.dst);
    }

    The generated .nuxt/vuetify/vuetify.settings.scss therefore contains:

    @use 'C:/Jenkins/workspace/pull request build/styles/settings.scss';
    @use 'vuetify/styles';

    which is exactly the failing form from Evidence 1.

    Evidence 3 — the other consumer of the same variable does convert it

    The same ctx.stylesConfigFile is passed to @vuetify/unplugin-styles:

    // L1129-1137
    } else if (typeof stylesOption === "object" && stylesOption !== null && "configFile" in stylesOption) {
      if (!ctx.stylesConfigFile) {
        throw new Error("vuetify-nuxt-module: styles.configFile could not be resolved");
      }
      const cache = resolveStylesCache(stylesOption);
      viteInlineConfig.plugins.push(Styles({
        settings: ctx.stylesConfigFile,
        ...

    and @vuetify/unplugin-styles wraps it before building its own @use:

    getTemplate(pathToFileURL(sassPath).href, pathToFileURL(configFile).href, isSCSS)

    So the Vite plugin path works on Windows and the Nuxt template path does not — a single
    inconsistency, not a path-content problem.

    Suggested fix

    pathToFileURL is already imported at the top of the file (L2), it is just not used here:

    // L229
    getContents: async () => getTemplate("vuetify/styles", pathToFileURL(ctx.stylesConfigFile).href)

    This mirrors what @vuetify/unplugin-styles already does for the same value, keeps both code
    paths consistent, and is a no-op on Linux/macOS (a file:// URL resolves identically there).

    Notes

    • The issue title mentions spaces, but any Windows path with styles.configFile set is affected;
      the reporter's path merely happened to contain one, which is why the space looked causal.
    • styles: true / styles: {} do not hit this branch, so only projects that set
      styles.configFile are affected — likely why this is not more widely reported.
    • Related: Windows environment does not exist. /.nuxt/vuetify.settings.scss #363 (same template, different Windows failure — virtual FS 404) was addressed by
      write: true; this is a separate defect in the same template.

    Verified on Windows, Node 24.18.0, sass-embedded 1.105.1, vuetify-nuxt-module 1.0.0-rc.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions