Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: data-uri, build-html plugins caches at buildStart #3535

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions packages/vite/src/node/plugins/dataUri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ const dataUriPrefix = `/@data-uri/`
* Build only, since importing from a data URI works natively.
*/
export function dataURIPlugin(): Plugin {
const resolved: {
let resolved: {
[key: string]: string
} = {}
}

return {
name: 'vite:data-uri',

buildStart() {
resolved = {}
},

resolveId(id) {
if (!dataUriRE.test(id)) {
return null
Expand Down
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function formatParseError(e: any, id: string, html: string): Error {
*/
export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
const [preHooks, postHooks] = resolveHtmlTransforms(config.plugins)
const processedHtml = new Map<string, string>()
let processedHtml: Map<string, string>
const isExcludedUrl = (url: string) =>
url.startsWith('#') ||
isExternalUrl(url) ||
Expand All @@ -149,6 +149,10 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
return {
name: 'vite:build-html',

buildStart() {
processedHtml = new Map<string, string>()
},

async transform(html, id) {
if (id.endsWith('.html')) {
const publicPath = `/${slash(path.relative(config.root, id))}`
Expand Down