diff --git a/.changeset/wild-panthers-try.md b/.changeset/wild-panthers-try.md new file mode 100644 index 0000000..bce48b8 --- /dev/null +++ b/.changeset/wild-panthers-try.md @@ -0,0 +1,5 @@ +--- +"@marko/vite": patch +--- + +Fix issue with mismatches MARKO_DEBUG environment and optimize compiler option. diff --git a/src/index.ts b/src/index.ts index 7b91d3e..dcb03a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; @@ -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,