Skip to content

Commit

Permalink
fix: sync MARKO_DEBUG and compiler optimize (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored Nov 16, 2023
1 parent b16a790 commit 3aca277
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wild-panthers-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fix issue with mismatches MARKO_DEBUG environment and optimize compiler option.
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
name: "marko-vite:pre",
enforce: "pre", // Must be pre to allow us to resolve assets before vite.
async config(config, env) {
let optimize = env.mode === "production";

if ("MARKO_DEBUG" in process.env) {
optimize =
process.env.MARKO_DEBUG === "false" ||
process.env.MARKO_DEBUG === "0";
} else {
process.env.MARKO_DEBUG = optimize ? "false" : "true";
}

compiler ??= (await import(
opts.compiler || "@marko/compiler"
)) as typeof Compiler;
Expand All @@ -165,10 +175,10 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {

baseConfig = {
cache,
optimize,
runtimeId,
sourceMaps: true,
writeVersionComment: false,
optimize: env.mode === "production",
babelConfig: opts.babelConfig
? {
...opts.babelConfig,
Expand Down

0 comments on commit 3aca277

Please sign in to comment.