{"id":21633,"library":"oc-vite","title":"Vite (oc-vite fork with external assets support)","description":"oc-vite is a modified fork of Vite that enables external asset support in library mode. Current stable version is 7.1.12. It follows Vite's release cadence and provides all Vite 7 features plus custom asset handling for library builds. The key differentiator is allowing users to configure external assets (e.g., images, fonts) as separate files instead of inlining them, which is useful for library authors publishing to npm. It ships TypeScript declarations and requires Node ^20.19.0 or >=22.12.0. Compared to standard Vite, oc-vite adds a specific hook or configuration option for library assets; otherwise identical to Vite in API and behavior.","status":"active","version":"7.1.12","language":"javascript","source_language":"en","source_url":"https://github.com/vitejs/vite","tags":["javascript","frontend","framework","hmr","dev-server","build-tool","vite","typescript"],"install":[{"cmd":"npm install oc-vite","lang":"bash","label":"npm"},{"cmd":"yarn add oc-vite","lang":"bash","label":"yarn"},{"cmd":"pnpm add oc-vite","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Vite is ESM-only since v4; CommonJS require is not supported. Always use ES module imports.","wrong":"const { defineConfig } = require('vite')","symbol":"defineConfig","correct":"import { defineConfig } from 'vite'"},{"note":"Do not use default import; named exports are preferred and consistently typed.","wrong":"import vite from 'vite'; vite.createServer()","symbol":"default (createServer)","correct":"import { createServer } from 'vite'"},{"note":"Use import type for TypeScript types to avoid runtime bundling. Valid for all Vite 5+.","wrong":"import { UserConfig } from 'vite'","symbol":"type UserConfig","correct":"import type { UserConfig } from 'vite'"}],"quickstart":{"code":"import { defineConfig } from 'vite'\nimport { resolve } from 'path'\n\nexport default defineConfig({\n  build: {\n    lib: {\n      entry: resolve(__dirname, 'src/index.ts'),\n      name: 'MyLib',\n      formats: ['es', 'cjs', 'umd'],\n    },\n    rollupOptions: {\n      external: ['react'],\n      output: {\n        globals: {\n          react: 'React',\n        },\n      },\n    },\n  },\n})","lang":"typescript","description":"Demonstrates a basic Vite library configuration with external dependencies and multiple output formats."},"warnings":[{"fix":"Switch to ESM imports (import { ... } from 'vite') or use dynamic import().","message":"Vite 5 dropped CommonJS support entirely; require() will fail.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Append file extensions e.g., import data from './data.json' with { assert: { type: 'json' } }.","message":"Since Vite 4, the default Node.js resolver no longer handles .json or .wasm imports without explicit extensions.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Wrap values in JSON.stringify() to avoid syntax errors, e.g., __APP_VERSION__: JSON.stringify('1.0.0').","message":"Using the `define` config option with strings that contain template literals can break due to unsafe minification.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use `optimizeDeps.include` and `optimizeDeps.exclude` explicitly instead.","message":"The `optimizeDeps.force` option is deprecated and no longer functional since Vite 6.","severity":"deprecated","affected_versions":">=6.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install vue@^3.2.13 or yarn add vue@^3.2.13.","cause":"Missing required peer dependency when using Vue plugin.","error":"Error: @vitejs/plugin-vue requires vue (>=3.2.13) or @vue/compiler-sfc to be present in the dependency tree."},{"fix":"Delete node_modules and package-lock.json, then run 'npm install' again. Alternatively, reinstall esbuild: 'npm rebuild esbuild'.","cause":"Incorrect esbuild binary for the current OS due to npm cache or wrong node version.","error":"Error: You installed esbuild on another platform than the one you're currently on. This won't work."},{"fix":"Run 'npm install vite' or 'yarn add vite'.","cause":"Vite not installed or not in node_modules.","error":"Error: Cannot find module 'vite'"},{"fix":"Ensure 'react/jsx-runtime' is installed (available in React 17+). Add to 'optimizeDeps.include' if needed.","cause":"Vite's pre-bundling fails to resolve certain React packages when using React 17/18 without the automatic JSX runtime.","error":"Error: Could not resolve 'react/jsx-runtime' (added by Vite's pre-bundling)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}