From df789cc412d6f7eb17dac6f6614383a7885db004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20Ledoux?= Date: Thu, 15 Apr 2021 21:39:06 -0500 Subject: [PATCH] docs: in vite-dev-server example don't require the config (#15866) * refactor: simplify vite example * docs: document the vite server options in TSDoc Co-authored-by: Lachlan Miller --- npm/vite-dev-server/cypress/plugins.js | 8 +++++--- npm/vite-dev-server/src/startServer.ts | 13 ++++++++++--- .../{vite.config.js => vite.config.ts} | 0 3 files changed, 15 insertions(+), 6 deletions(-) rename npm/vite-dev-server/{vite.config.js => vite.config.ts} (100%) diff --git a/npm/vite-dev-server/cypress/plugins.js b/npm/vite-dev-server/cypress/plugins.js index 05b49d512860..9b1e592f9c98 100644 --- a/npm/vite-dev-server/cypress/plugins.js +++ b/npm/vite-dev-server/cypress/plugins.js @@ -1,11 +1,13 @@ -import { startDevServer } from '@cypress/vite-dev-server' -import viteConfig from '../vite.config' +const path = require('path') +const { startDevServer } = require('../dist') module.exports = (on, config) => { on('dev-server:start', async (options) => { return startDevServer({ options, - viteConfig, + viteConfig: { + configFile: path.resolve(__dirname, '..', 'vite.config.ts'), + }, }) }) diff --git a/npm/vite-dev-server/src/startServer.ts b/npm/vite-dev-server/src/startServer.ts index ad75828a4ef1..20f0d5efdbfc 100644 --- a/npm/vite-dev-server/src/startServer.ts +++ b/npm/vite-dev-server/src/startServer.ts @@ -14,10 +14,17 @@ interface Options { } export interface StartDevServer { - /* this is the Cypress options object */ + /** + * the Cypress options object + */ options: Options - /* support passing a path to the user's webpack config */ - viteConfig?: UserConfig // TODO: implement taking in the user's vite configuration. Right now we don't + /** + * By default, vite will use your vite.config file to + * Start the server. If you need additional plugins or + * to override some options, you can do so using this. + * @optional + */ + viteConfig?: UserConfig } const resolveServerConfig = async ({ viteConfig, options }: StartDevServer): Promise => { diff --git a/npm/vite-dev-server/vite.config.js b/npm/vite-dev-server/vite.config.ts similarity index 100% rename from npm/vite-dev-server/vite.config.js rename to npm/vite-dev-server/vite.config.ts