Skip to content

Commit

Permalink
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.
  • Loading branch information
jamiebrynes7 committed Mar 13, 2024
1 parent b5f2e80 commit 1aa82c2
Show file tree
Hide file tree
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
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions plugin/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1aa82c2

Please sign in to comment.