MCPcopy
hub / github.com/vitejs/vite / configureServer

Function configureServer

packages/vite/src/node/plugins/forwardConsole.ts:19–50  ·  view source on GitHub ↗
(server)

Source from the content-addressed store, hash-verified

17 name: 'vite:forward-console',
18 apply: 'serve',
19 configureServer(server) {
20 for (const name of pluginOpts.environments) {
21 const environment = server.environments[name]
22 environment.hot.on('vite:forward-console', (payload) => {
23 if (
24 payload.type === 'error' ||
25 payload.type === 'unhandled-rejection'
26 ) {
27 const output = formatError(payload, environment, sourceMapCache)
28 environment.config.logger.error(output, {
29 timestamp: true,
30 })
31 } else {
32 const output =
33 c.dim(`[console.${payload.data.level}] `) + payload.data.message
34 if (payload.data.level === 'error') {
35 environment.config.logger.error(output, {
36 timestamp: true,
37 })
38 } else if (payload.data.level === 'warn') {
39 environment.config.logger.warn(output, {
40 timestamp: true,
41 })
42 } else {
43 environment.config.logger.info(output, {
44 timestamp: true,
45 })
46 }
47 }
48 })
49 }
50 },
51 }
52}
53

Callers

nothing calls this directly

Calls 5

formatErrorFunction · 0.85
onMethod · 0.65
errorMethod · 0.65
warnMethod · 0.65
infoMethod · 0.65

Tested by

no test coverage detected