Skip to content

Ensuring Cypress configures correct bundler from a custom framework definitionΒ #31048

Open
@nnaydenow

Description

@nnaydenow

Current behavior

I'm creating a custom framework definition using the Cypress CT definition template, as outlined in the Cypress documentation.

I modified the template to support only vite as the bundler:

export default defineComponentFramework({
  type: "cypress-ct-template",
  name: "Example Dependency",
  supportedBundlers: ["vite"],
  detectors: [dep],
  dependencies: (bundler) => {
    return [dep];
  },
});

However, when setting up Cypress through the wizard using this framework definition, the generated cypress.config.js file incorrectly configures webpack as the bundler:

Image

Even though Cypress detects webpack in the next step (which comes from another dependency and should not be used). Additionally, I have a vite.config.js file in the project root.

Image

After completing the wizard, the resulting Cypress configuration looks like this:

import { defineConfig } from "cypress";

export default defineConfig({
  component: {
    devServer: {
      framework: "my-custom-framework",
      bundler: "webpack",
    },
  },
});

Despite explicitly setting supportedBundlers: ["vite"], Cypress still selects webpack. How can I ensure that vite is correctly configured instead?

Desired behavior

Cypress should correctly set vite as the bundler in cypress.config.js, ensuring it aligns with the custom framework's supportedBundlers: ["vite"] configuration.

Test code to reproduce

  1. Clone cypress-ct-definition-template.
  2. Change supportedBundlers to ["vite"]
  3. In a simple project, initialize a new package.json (npm init in the folder) and install Cypress along with the newly created definition from the template.
  4. Run npx cypress open and npx cypress open --component.

Cypress Version

14.0.2

Node version

v20.11.0

Operating System

macOS 15.2

Debug Logs

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    CTIssue related to component testing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions