vite.config.js — vite Source File
Architecture documentation for vite.config.js, a javascript file in the vite codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 7b625b34_87b9_5eea_dd95_0b01e75f0d0a["vite.config.js"] a09ff191_7c83_bdcd_30f1_b4e129910bf6["promises"] 7b625b34_87b9_5eea_dd95_0b01e75f0d0a --> a09ff191_7c83_bdcd_30f1_b4e129910bf6 51e96894_3556_ed5c_1ede_97d449867adf["node:path"] 7b625b34_87b9_5eea_dd95_0b01e75f0d0a --> 51e96894_3556_ed5c_1ede_97d449867adf 54c37fea_4fe7_2693_71cb_1276b77f55f9["vite"] 7b625b34_87b9_5eea_dd95_0b01e75f0d0a --> 54c37fea_4fe7_2693_71cb_1276b77f55f9 style 7b625b34_87b9_5eea_dd95_0b01e75f0d0a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fs from 'node:fs/promises'
import path from 'node:path'
import { defineConfig } from 'vite'
const npmDirectServeConfig = {
'/vue@3.4.38.js': 'vue34/dist/vue.runtime.esm-browser.js',
'/slash@5.js': 'slash5/index.js',
}
/** @type {import('vite').Connect.NextHandleFunction} */
const serveNpmCodeDirectlyMiddleware = async (req, res, next) => {
for (const [url, file] of Object.entries(npmDirectServeConfig)) {
if (req.originalUrl === url) {
const code = await fs.readFile(
new URL(`./node_modules/${file}`, import.meta.url),
)
res.setHeader('Content-Type', 'text/javascript')
res.end(code)
return
}
}
next()
}
export default defineConfig({
optimizeDeps: {
include: ['dep-that-imports', 'dep-that-requires'],
exclude: ['vue', 'slash5'],
},
build: {
minify: false,
rollupOptions: {
external: ['vue', 'slash3', 'slash5'],
transform: {
inject: {
require: path.resolve(import.meta.dirname, 'src/require-polyfill.js'),
},
},
},
commonjsOptions: {
esmExternals: ['vue', 'slash5'],
dynamicRequireTargets: ['test-no-op-fdir-glob'],
},
},
plugins: [
{
name: 'serve-npm-code-directly',
configureServer({ middlewares }) {
middlewares.use(serveNpmCodeDirectlyMiddleware)
},
configurePreviewServer({ middlewares }) {
middlewares.use(serveNpmCodeDirectlyMiddleware)
},
},
],
})
Domain
Subdomains
Functions
Dependencies
- node:path
- promises
- vite
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 1 function(s): serveNpmCodeDirectlyMiddleware.
What does vite.config.js depend on?
vite.config.js imports 3 module(s): node:path, promises, vite.
Where is vite.config.js in the architecture?
vite.config.js is located at playground/external/vite.config.js (domain: ViteCore, subdomain: ConfigEngine, directory: playground/external).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free