vite.config.js — vite Source File
Architecture documentation for vite.config.js, a javascript file in the vite codebase. 2 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 27181c23_86dc_103e_6360_405313c9a075["vite.config.js"] 51e96894_3556_ed5c_1ede_97d449867adf["node:path"] 27181c23_86dc_103e_6360_405313c9a075 --> 51e96894_3556_ed5c_1ede_97d449867adf 54c37fea_4fe7_2693_71cb_1276b77f55f9["vite"] 27181c23_86dc_103e_6360_405313c9a075 --> 54c37fea_4fe7_2693_71cb_1276b77f55f9 8a43bc50_8d6b_8019_4b93_a3370956c3d7["vite.config-base.js"] 8a43bc50_8d6b_8019_4b93_a3370956c3d7 --> 27181c23_86dc_103e_6360_405313c9a075 style 27181c23_86dc_103e_6360_405313c9a075 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { resolve } from 'node:path'
import { defineConfig, normalizePath } from 'vite'
const file = normalizePath(resolve(import.meta.dirname, 'index.js'))
let transformCount = 1
const transformPlugin = {
name: 'transform',
load(id) {
if (id === file) {
// Ensure `index.js` is reloaded if 'plugin-dep-load.js' is changed
this.addWatchFile('./plugin-dep-load.js')
}
},
transform(code, id) {
if (id === file) {
// Ensure `index.js` is reevaluated if 'plugin-dep.js' is changed
this.addWatchFile('./plugin-dep.js')
return `
// Inject TRANSFORM_COUNT
let TRANSFORM_COUNT = ${transformCount++};
${code}
`
}
},
}
const moduleTypePlugins = [
/** @type {const} */ ...['pre', 'post'].map((enforce) => ({
name: `module-type-${enforce}`,
enforce,
transform(code, id, opts) {
if (id.endsWith('/foo.json') || id.endsWith('\0/bar.json')) {
code = code.replace(
`MODULE_TYPE_${enforce.toUpperCase()}`,
opts.moduleType,
)
return code
}
},
})),
{
name: `module-type-load`,
resolveId(id) {
if (id === 'virtual:/bar.json') {
return '\0/bar.json'
}
},
load(id) {
if (id.endsWith('\0/bar.json')) {
return JSON.stringify({
moduleTypePre: 'MODULE_TYPE_PRE',
moduleTypePost: 'MODULE_TYPE_POST',
})
}
},
},
]
const lazyHookFilterPlugin = {
name: 'lazy-hook-filter',
options() {
lazyHookFilterPlugin.transform.filter = { id: '**/index.js' }
},
transform: {
filter: /** @type {import('vite').Rolldown.HookFilter} */ ({
id: { exclude: ['**/*.js'] },
}),
handler(code) {
return code.replaceAll('LAZY_HOOK_FILTER_CONTENT', 'success')
},
},
}
export default defineConfig({
plugins: [transformPlugin, moduleTypePlugins, lazyHookFilterPlugin],
})
Domain
Subdomains
Functions
Dependencies
- node:path
- vite
Imported By
Source
Frequently Asked Questions
What does vite.config.js do?
vite.config.js is a source file in the vite codebase, written in javascript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in vite.config.js?
vite.config.js defines 4 function(s): lazyHookFilterPlugin.options, moduleTypePlugins, transformPlugin.load, transformPlugin.transform.
What does vite.config.js depend on?
vite.config.js imports 2 module(s): node:path, vite.
What files import vite.config.js?
vite.config.js is imported by 1 file(s): vite.config-base.js.
Where is vite.config.js in the architecture?
vite.config.js is located at playground/transform-plugin/vite.config.js (domain: ViteCore, subdomain: ConfigEngine, directory: playground/transform-plugin).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free