Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace NODE_ENV at build time
Browse files Browse the repository at this point in the history
With react, it tries to read from process.env, but this fails on mobile leading to the plugin failing to load.

By replacing this at build-time, we can sidestep this issue.
jamiebrynes7 committed Mar 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b5f2e80 commit 1aa82c2
Showing 3 changed files with 55 additions and 0 deletions.
50 changes: 50 additions & 0 deletions plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugin/package.json
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.5.3",
"@rollup/plugin-replace": "^5.0.5",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
4 changes: 4 additions & 0 deletions plugin/vite.config.mts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { svelte } from "@sveltejs/vite-plugin-svelte";
import { viteStaticCopy } from "vite-plugin-static-copy";
import path, { resolve } from "path";
import { loadEnv } from "vite";
import replace from '@rollup/plugin-replace';

function getOutDir(): string | undefined {
const env = loadEnv("prod", process.cwd());
@@ -31,6 +32,9 @@ export default defineConfig({
},
],
}),
replace({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
})
],
build: {
// We aren't building a website, so we build in library mode

0 comments on commit 1aa82c2

Please sign in to comment.