Skip to content

fix: do not inject env vars into non-source files - #13001

Merged
ascorbic merged 1 commit into
mainfrom
env-assets
Jan 17, 2025
Merged

ascorbic merged 1 commit into
mainfrom
env-assets

Conversation

@ascorbic

@ascorbic ascorbic commented Jan 17, 2025 •

Copy link
Copy Markdown
Contributor

Changes

Currently vite-plugin-import-meta-env injects a runtime into any file that includes the string import.meta.env, which enables the use of env vars. Unfortunately this meant it also did this to non-source files such as JSON, CSS and HTML files that include that string. This caused performance issues like #12999, but could also break builds entirely in some cases where the asset wasn't transformed to JS.

This PR filters the file types more comprehensively.

Fixes #12999

Testing

Adds test cases

Docs

@changeset-bot

changeset-bot Bot commented Jan 17, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 863df8d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Jan 17, 2025
@codspeed

codspeed Bot commented Jan 17, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #13001 will not alter performance

Comparing env-assets (863df8d) with main (78fd73a)

Summary

✅ 6 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sourcemaps generated for astro:data-layer-content causing slow astro dev reloads

2 participants