Skip to content

Commit 2173300

Browse files
authored
docs: add dev server function config API (#4699)
* docs: add dev server function config API * update docs
1 parent 4e2f2b2 commit 2173300

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

content/guides/component-testing/component-framework-configuration.md

+51
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ module.exports = defineConfig({
215215
devServer: {
216216
framework: 'react',
217217
bundler: 'vite',
218+
// optionally pass in vite config
219+
viteConfig: require('./webpack.config'),
220+
// or a function - the result is merged with
221+
// any `vite.config` file that is detected
222+
viteConfig: async () => {
223+
// ... do things ...
224+
const modifiedConfig = await injectCustomConfig(baseConfig)
225+
return modifiedConfig
226+
},
218227
},
219228
},
220229
})
@@ -225,12 +234,22 @@ module.exports = defineConfig({
225234

226235
```ts
227236
import { defineConfig } from 'cypress'
237+
import customViteConfig from './customConfig'
228238

229239
export default defineConfig({
230240
component: {
231241
devServer: {
232242
framework: 'react',
233243
bundler: 'vite',
244+
// optionally pass in vite config
245+
viteConfig: customViteConfig,
246+
// or a function - the result is merged with
247+
// any `vite.config` file that is detected
248+
viteConfig: async () => {
249+
// ... do things ...
250+
const modifiedConfig = await injectCustomConfig(baseConfig)
251+
return modifiedConfig
252+
},
234253
},
235254
},
236255
})
@@ -260,6 +279,13 @@ module.exports = {
260279
bundler: 'webpack',
261280
// optionally pass in webpack config
262281
webpackConfig: require('./webpack.config'),
282+
// or a function - the result is merged with any
283+
// webpack.config that is found
284+
webpackConfig: async () => {
285+
// ... do things ...
286+
const modifiedConfig = await injectCustomConfig(baseConfig)
287+
return modifiedConfig
288+
},
263289
},
264290
},
265291
}
@@ -279,6 +305,13 @@ export default defineConfig({
279305
bundler: 'webpack',
280306
// optionally pass in webpack config
281307
webpackConfig,
308+
// or a function - the result is merged with any
309+
// webpack.config that is found
310+
webpackConfig: async () => {
311+
// ... do things ...
312+
const modifiedConfig = await injectCustomConfig(baseConfig)
313+
return modifiedConfig
314+
},
282315
},
283316
},
284317
})
@@ -472,6 +505,13 @@ module.exports = {
472505
bundler: 'webpack',
473506
// optionally pass in webpack config
474507
webpackConfig: require('./webpack.config'),
508+
// or a function - the result is merged with any
509+
// webpack.config that is found
510+
webpackConfig: async () => {
511+
// ... do things ...
512+
const modifiedConfig = await injectCustomConfig(baseConfig)
513+
return modifiedConfig
514+
},
475515
},
476516
},
477517
}
@@ -491,6 +531,11 @@ export default defineConfig({
491531
bundler: 'webpack',
492532
// optionally pass in webpack config
493533
webpackConfig,
534+
webpackConfig: async () => {
535+
// ... do things ...
536+
const modifiedConfig = await injectCustomConfig(baseConfig)
537+
return modifiedConfig
538+
},
494539
},
495540
},
496541
})
@@ -675,6 +720,12 @@ module.exports = {
675720
bundler: 'webpack',
676721
// optionally pass in webpack config
677722
webpackConfig: require('./webpack.config'),
723+
// or a function - the result is merged with the base config
724+
webpackConfig: async () => {
725+
// ... do things ...
726+
const modifiedConfig = await injectCustomConfig(baseConfig)
727+
return modifiedConfig
728+
},
678729
},
679730
},
680731
}

0 commit comments

Comments
 (0)