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

Function prepareOutDirPlugin

packages/vite/src/node/plugins/prepareOutDir.ts:11–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9import { withTrailingSlash } from '../../shared/utils'
10
11export function prepareOutDirPlugin(): Plugin {
12 const rendered = new Set<Environment>()
13 return {
14 name: 'vite:prepare-out-dir',
15 watchChange() {
16 rendered.delete(this.environment)
17 },
18 renderStart: {
19 order: 'pre',
20 handler() {
21 if (rendered.has(this.environment)) {
22 return
23 }
24
25 const { config } = this.environment
26 if (config.build.write) {
27 rendered.add(this.environment)
28 const { root, build: options } = config
29 const resolvedOutDirs = getResolvedOutDirs(
30 root,
31 options.outDir,
32 options.rolldownOptions.output,
33 )
34 const emptyOutDir = resolveEmptyOutDir(
35 options.emptyOutDir,
36 root,
37 resolvedOutDirs,
38 this.environment.logger,
39 )
40 prepareOutDir(resolvedOutDirs, emptyOutDir, this.environment)
41 }
42 },
43 },
44 }
45}
46
47function prepareOutDir(
48 outDirs: Set<string>,

Callers 1

resolveBuildPluginsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected