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: do not inject env vars into non-source files #13001

Merged
merged 1 commit into from
Jan 17, 2025
Merged

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

merged 1 commit into from
Jan 17, 2025

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Jan 17, 2025

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

Copy link

changeset-bot bot commented Jan 17, 2025

🦋 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
Copy link

codspeed-hq bot commented Jan 17, 2025

CodSpeed Performance Report

Merging #13001 will not alter performance

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

Summary

✅ 6 untouched benchmarks

@ascorbic ascorbic merged commit 627aec3 into main Jan 17, 2025
16 checks passed
@ascorbic ascorbic deleted the env-assets branch January 17, 2025 12:34
@astrobot-houston astrobot-houston mentioned this pull request Jan 17, 2025
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