Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/vite/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ declare module '*?url&inline' {
export default src
}

declare module '*?url&no-inline' {
const src: string
export default src
}

declare interface VitePreloadErrorEvent extends Event {
payload: Error
}
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const assetUrlRE = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g

const jsSourceMapRE = /\.[cm]?js\.map$/

const noInlineRE = /[?&]no-inline\b/
const inlineRE = /[?&]inline\b/
export const noInlineRE = /[?&]no-inline\b/
export const inlineRE = /[?&]inline\b/
const svgExtRE = /\.svg(?:$|\?)/

const assetCache = new WeakMap<Environment, Map<string, string>>()
Expand Down
9 changes: 9 additions & 0 deletions packages/vite/src/node/plugins/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { dataToEsm, makeLegalIdentifier } from '@rollup/pluginutils'
import { SPECIAL_QUERY_RE } from '../constants'
import type { Plugin } from '../plugin'
import { stripBomTag } from '../utils'
import { inlineRE, noInlineRE } from './asset'

export interface JsonOptions {
/**
Expand Down Expand Up @@ -47,6 +48,14 @@ export function jsonPlugin(
if (!jsonExtRE.test(id)) return null
if (SPECIAL_QUERY_RE.test(id)) return null

if (inlineRE.test(id) || noInlineRE.test(id)) {
this.warn(
`\n` +
`Using ?inline or ?no-inline for JSON imports will have no effect.\n` +
`Please use ?url&inline or ?url&no-inline to control JSON file inlining behavior.\n`,
)
}

json = stripBomTag(json)

try {
Expand Down