From b59c6fa2ec31484718aae67a23dff81b8f5b4b9e Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Wed, 31 Aug 2022 18:04:26 +1000 Subject: [PATCH 1/2] docs: add dev server function config API --- .../component-framework-configuration.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/content/guides/component-testing/component-framework-configuration.md b/content/guides/component-testing/component-framework-configuration.md index 73a33b3c32..f0b3a33433 100644 --- a/content/guides/component-testing/component-framework-configuration.md +++ b/content/guides/component-testing/component-framework-configuration.md @@ -215,6 +215,14 @@ module.exports = defineConfig({ devServer: { framework: 'react', bundler: 'vite', + // optionally pass in vite config + viteConfig: require('./webpack.config'), + // or a function - the result is merged with the base config + viteConfig: async (baseConfig) => { + // ... do things ... + const modifiedConfig = await injectCustomConfig(baseConfig) + return modifiedConfig + }, }, }, }) @@ -225,12 +233,21 @@ module.exports = defineConfig({ ```ts import { defineConfig } from 'cypress' +import customViteConfig from './customConfig' export default defineConfig({ component: { devServer: { framework: 'react', bundler: 'vite', + // optionally pass in vite config + viteConfig: customViteConfig, + // or a function - the result is merged with the base config + viteConfig: async (baseConfig) => { + // ... do things ... + const modifiedConfig = await injectCustomConfig(baseConfig) + return modifiedConfig + }, }, }, }) @@ -260,6 +277,12 @@ module.exports = { bundler: 'webpack', // optionally pass in webpack config webpackConfig: require('./webpack.config'), + // or a function - the result is merged with the base config + webpackConfig: async (baseConfig) => { + // ... do things ... + const modifiedConfig = await injectCustomConfig(baseConfig) + return modifiedConfig + }, }, }, } @@ -279,6 +302,12 @@ export default defineConfig({ bundler: 'webpack', // optionally pass in webpack config webpackConfig, + // or a function - the result is merged with the base config + webpackConfig: async (baseConfig) => { + // ... do things ... + const modifiedConfig = await injectCustomConfig(baseConfig) + return modifiedConfig + }, }, }, }) @@ -472,6 +501,12 @@ module.exports = { bundler: 'webpack', // optionally pass in webpack config webpackConfig: require('./webpack.config'), + // or a function - the result is merged with the base config + webpackConfig: async (baseConfig) => { + // ... do things ... + const modifiedConfig = await injectCustomConfig(baseConfig) + return modifiedConfig + }, }, }, } @@ -491,6 +526,11 @@ export default defineConfig({ bundler: 'webpack', // optionally pass in webpack config webpackConfig, + webpackConfig: async (baseConfig) => { + // ... do things ... + const modifiedConfig = await injectCustomConfig(baseConfig) + return modifiedConfig + }, }, }, }) @@ -675,6 +715,12 @@ module.exports = { bundler: 'webpack', // optionally pass in webpack config webpackConfig: require('./webpack.config'), + // or a function - the result is merged with the base config + webpackConfig: async (baseConfig) => { + // ... do things ... + const modifiedConfig = await injectCustomConfig(baseConfig) + return modifiedConfig + }, }, }, } From 85074c27c0e52cf71e01496b8e5ee4c805a286f4 Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Thu, 15 Sep 2022 11:39:02 +1000 Subject: [PATCH 2/2] update docs --- .../component-framework-configuration.md | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/content/guides/component-testing/component-framework-configuration.md b/content/guides/component-testing/component-framework-configuration.md index f0b3a33433..af54219aec 100644 --- a/content/guides/component-testing/component-framework-configuration.md +++ b/content/guides/component-testing/component-framework-configuration.md @@ -217,8 +217,9 @@ module.exports = defineConfig({ bundler: 'vite', // optionally pass in vite config viteConfig: require('./webpack.config'), - // or a function - the result is merged with the base config - viteConfig: async (baseConfig) => { + // or a function - the result is merged with + // any `vite.config` file that is detected + viteConfig: async () => { // ... do things ... const modifiedConfig = await injectCustomConfig(baseConfig) return modifiedConfig @@ -242,8 +243,9 @@ export default defineConfig({ bundler: 'vite', // optionally pass in vite config viteConfig: customViteConfig, - // or a function - the result is merged with the base config - viteConfig: async (baseConfig) => { + // or a function - the result is merged with + // any `vite.config` file that is detected + viteConfig: async () => { // ... do things ... const modifiedConfig = await injectCustomConfig(baseConfig) return modifiedConfig @@ -277,8 +279,9 @@ module.exports = { bundler: 'webpack', // optionally pass in webpack config webpackConfig: require('./webpack.config'), - // or a function - the result is merged with the base config - webpackConfig: async (baseConfig) => { + // or a function - the result is merged with any + // webpack.config that is found + webpackConfig: async () => { // ... do things ... const modifiedConfig = await injectCustomConfig(baseConfig) return modifiedConfig @@ -302,8 +305,9 @@ export default defineConfig({ bundler: 'webpack', // optionally pass in webpack config webpackConfig, - // or a function - the result is merged with the base config - webpackConfig: async (baseConfig) => { + // or a function - the result is merged with any + // webpack.config that is found + webpackConfig: async () => { // ... do things ... const modifiedConfig = await injectCustomConfig(baseConfig) return modifiedConfig @@ -501,8 +505,9 @@ module.exports = { bundler: 'webpack', // optionally pass in webpack config webpackConfig: require('./webpack.config'), - // or a function - the result is merged with the base config - webpackConfig: async (baseConfig) => { + // or a function - the result is merged with any + // webpack.config that is found + webpackConfig: async () => { // ... do things ... const modifiedConfig = await injectCustomConfig(baseConfig) return modifiedConfig @@ -526,7 +531,7 @@ export default defineConfig({ bundler: 'webpack', // optionally pass in webpack config webpackConfig, - webpackConfig: async (baseConfig) => { + webpackConfig: async () => { // ... do things ... const modifiedConfig = await injectCustomConfig(baseConfig) return modifiedConfig @@ -716,7 +721,7 @@ module.exports = { // optionally pass in webpack config webpackConfig: require('./webpack.config'), // or a function - the result is merged with the base config - webpackConfig: async (baseConfig) => { + webpackConfig: async () => { // ... do things ... const modifiedConfig = await injectCustomConfig(baseConfig) return modifiedConfig