-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: inject
process.env.NODE_ENV
for third party libs (#2481)
- Loading branch information
1 parent
88c3671
commit 9347b84
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useEffect } from "preact/hooks"; | ||
import { useSignal } from "@preact/signals"; | ||
import { IS_BROWSER } from "@fresh/core/runtime"; | ||
|
||
export function NodeProcess() { | ||
const active = useSignal(false); | ||
|
||
useEffect(() => { | ||
active.value = true; | ||
}, []); | ||
|
||
// @ts-ignore bundling | ||
const value = IS_BROWSER ? process.env.NODE_ENV : "no"; | ||
|
||
return ( | ||
<div class={active.value ? "ready" : ""}> | ||
value: {value} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters