Skip to content

When using the defineConfig function, the fmt configuration item does not take effect #825

Closed as duplicate

Description

@FrontEndDog

Describe the bug

Use the following configuration

import { defineConfig } from "vite-plus";

export default defineConfig(() => {
  return {
    fmt: { printWidth: 120, singleQuote: true, semi: false },
    lint: { options: { typeAware: true, typeCheck: true } },
  };
});

will appear

gwq@yizhiqianduanwangdeMacBook-Pro vp-test % vp fmt --check
VITE+ - The Unified Toolchain for the Web

Failed to load configuration file.
Expected a `fmt` field in the default export of /Users/gwq/Desktop/vp-test/vite.config.ts

However, the following configuration is normal

import { defineConfig } from "vite-plus";

export default defineConfig({
    fmt: { printWidth: 120, singleQuote: true, semi: false },
    lint: { options: { typeAware: true, typeCheck: true } },
});

Reproduction

Steps to reproduce

No response

System Info

gwq@yizhiqianduanwangdeMacBook-Pro vp-test % vp env current
VITE+ - The Unified Toolchain for the Web

Environment:
  Version  24.14.0
  Source   lts

Tool Paths:
  node  /Users/gwq/.vite-plus/js_runtime/node/24.14.0/bin/node
  npm   /Users/gwq/.vite-plus/js_runtime/node/24.14.0/bin/npm
  npx   /Users/gwq/.vite-plus/js_runtime/node/24.14.0/bin/npx


gwq@yizhiqianduanwangdeMacBook-Pro vp-test % vp --version
VITE+ - The Unified Toolchain for the Web

vp v0.1.11

Local vite-plus:
  vite-plus  v0.1.11

Tools:
  vite             v8.0.0
  rolldown         v1.0.0-rc.9
  vitest           v4.1.0
  oxfmt            v0.40.0
  oxlint           v1.55.0
  oxlint-tsgolint  v0.16.0
  tsdown           v0.21.2

Used Package Manager

pnpm

Logs

Validations

Activity

  1. added theissue type on Mar 13, 2026
  2. xMikuzoo commented on Mar 13, 2026

    @xMikuzoo

    Same issue. In my case I need the function form to access mode for conditionally loading plugins:

    export default defineConfig(({ mode }) => ({
      fmt: { ... },
      lint: { ... },
      staged: { "*": "vp check --fix" },
      plugins: [
        mode === "production" && somePlugin({ ... }),
      ],
    }));
    Failed to load configuration file.
    Expected a `fmt` field in the default export of vite.config.ts
    

    Switching to a static object works around it, but I'm not sure how to access mode without the function form.

    vp v0.1.11, Windows, npm@11.11.1

  3. CSY54 commented on Mar 15, 2026

    @CSY54

    It looks like vp lint also has the same issue as vp fmt when the configuration is written in function form.

    // vite.config.ts
    import { defineConfig } from "vite-plus";
    
    export default defineConfig(({ mode }) => ({
      staged: {
        "*": "vp check --fix",
      },
      lint: { options: { typeAware: true, typeCheck: true } },
      fmt: {
        semi: false,
        singleQuote: true,
      },
    }));
    ❯  vp fmt
    VITE+ - The Unified Toolchain for the Web
    
    Failed to load configuration file.
    Expected a `fmt` field in the default export of vite.config.ts
    
    ❯  vp lint
    VITE+ - The Unified Toolchain for the Web
    
    Failed to parse oxlint configuration file.
    
      × Expected a `lint` field in the default export of vite.config.ts
    
  4. leaysgur commented on Mar 16, 2026

    @leaysgur
    Contributor

    Thank you for the report~!
    Please use this link for tracking purposes going forward.

    #930

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions