Skip to content

Commit

Permalink
fix(mdx): #23 missing process.env.NODE_ENV if MDX is used with CLI
Browse files Browse the repository at this point in the history
Closes: #23
  • Loading branch information
sdorra committed Mar 29, 2024
1 parent 86ebc84 commit 1a1e371
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-laws-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@content-collections/mdx": patch
---

Fix missing process.env.NODE_ENV if mdx is used with cli
8 changes: 8 additions & 0 deletions packages/mdx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ async function compile(document: Document, options: Options = {}) {
source: document.content,
cwd: options.cwd,
files,
esbuildOptions(options) {
if (!options.define) {
options.define = {};
}
const env = process.env.NODE_ENV ?? "production";
options.define["process.env.NODE_ENV"] = JSON.stringify(env);
return options;
},
mdxOptions(mdxOptions) {
mdxOptions.rehypePlugins = [
...(options.rehypePlugins ?? []),
Expand Down

0 comments on commit 1a1e371

Please sign in to comment.