Home / File/ vite.config-runtime-base.js — vite Source File

vite.config-runtime-base.js — vite Source File

Architecture documentation for vite.config-runtime-base.js, a javascript file in the vite codebase. 2 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  5765d743_85ee_42dc_126c_5de2d401b76a["vite.config-runtime-base.js"]
  f86de0e1_d1c4_a5fa_5256_854f3d35619b["vite.config.js"]
  5765d743_85ee_42dc_126c_5de2d401b76a --> f86de0e1_d1c4_a5fa_5256_854f3d35619b
  54c37fea_4fe7_2693_71cb_1276b77f55f9["vite"]
  5765d743_85ee_42dc_126c_5de2d401b76a --> 54c37fea_4fe7_2693_71cb_1276b77f55f9
  style 5765d743_85ee_42dc_126c_5de2d401b76a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { defineConfig } from 'vite'
import baseConfig from './vite.config.js'

const dynamicBaseAssetsCode = `
globalThis.__toAssetUrl = url => '/' + url
globalThis.__publicBase = '/'
`

export default defineConfig({
  ...baseConfig,
  base: './', // overwrite the original base: '/foo/'
  build: {
    ...baseConfig.build,
    outDir: 'dist/runtime-base',
    watch: null,
    minify: false,
    assetsInlineLimit: 0,
    rollupOptions: {
      output: {
        entryFileNames: 'entries/[name].js',
        chunkFileNames: 'chunks/[name]-[hash].js',
        assetFileNames: 'other-assets/[name]-[hash][extname]',
      },
    },
  },
  plugins: [
    {
      name: 'dynamic-base-assets-globals',
      transformIndexHtml(_, ctx) {
        if (ctx.bundle) {
          // Only inject during build
          return [
            {
              tag: 'script',
              attrs: { type: 'module' },
              children: dynamicBaseAssetsCode,
            },
          ]
        }
      },
    },
  ],
  experimental: {
    renderBuiltUrl(filename, { hostType, type }) {
      if (type === 'asset') {
        if (hostType === 'js') {
          return {
            runtime: `globalThis.__toAssetUrl(${JSON.stringify(filename)})`,
          }
        }
      } else if (type === 'public') {
        if (hostType === 'js') {
          return {
            runtime: `globalThis.__publicBase+${JSON.stringify(filename)}`,
          }
        }
      }
    },
  },
  cacheDir: 'node_modules/.vite-runtime-base',
})

Domain

Dependencies

Frequently Asked Questions

What does vite.config-runtime-base.js do?
vite.config-runtime-base.js is a source file in the vite codebase, written in javascript. It belongs to the ViteCore domain.
What does vite.config-runtime-base.js depend on?
vite.config-runtime-base.js imports 2 module(s): vite, vite.config.js.
Where is vite.config-runtime-base.js in the architecture?
vite.config-runtime-base.js is located at playground/assets/vite.config-runtime-base.js (domain: ViteCore, directory: playground/assets).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free