import { pathToFileURL } from 'node:url' import MagicString from 'magic-string' import { parseQuery, parseURL } from 'ufo' import type { Plugin } from 'vite' import { isCSS } from '../utils' interface RuntimePathsOptions { sourcemap?: boolean } const VITE_ASSET_RE = /__VITE_ASSET__|__VITE_PUBLIC_ASSET__/ export function runtimePathsPlugin (options: RuntimePathsOptions): Plugin { return { name: 'nuxt:runtime-paths-dep', enforce: 'post', transform (code, id) { const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href)) // skip import into css files if (isCSS(pathname)) { return } // skip import into