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
2 changes: 1 addition & 1 deletion packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
if (isLegacyBundle(bundle, opts) && genModern) {
// avoid emitting duplicate assets
for (const name in bundle) {
if (bundle[name].type === 'asset' && !/.+\.map$/.test(name)) {
if (bundle[name].type === 'asset' && !name.endsWith('.map')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It now matches ".map" but I think that's fine.

delete bundle[name]
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const jsSourceMapRE = /\.[cm]?js\.map$/

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

const assetCache = new WeakMap<Environment, Map<string, string>>()

Expand Down Expand Up @@ -308,7 +307,7 @@ export async function fileToDevUrl(
// If is svg and it's inlined in build, also inline it in dev to match
// the behaviour in build due to quote handling differences.
const cleanedId = cleanUrl(id)
if (svgExtRE.test(cleanedId)) {
if (cleanedId.endsWith('.svg')) {
Comment on lines 309 to +310
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanUrl strips anything after the first ? so /\.svg(?:$|\?)/ is equivalent to /\.svg$/ here.

const file = publicFile || cleanedId
const content = await fsp.readFile(file)
if (shouldInline(environment, file, id, content, undefined, undefined)) {
Expand Down
Loading