Skip to content

Commit

Permalink
fix: respect 'mode' CLI flag when running dev command
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Nazarev committed Apr 24, 2024
1 parent fc097e8 commit a987a1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nine-buttons-push.md
@@ -0,0 +1,5 @@
---
"astro": patch
---

respect "mode" CLI flag when running dev command
2 changes: 1 addition & 1 deletion packages/astro/src/core/dev/container.ts
Expand Up @@ -68,7 +68,7 @@ export async function createContainer({

const viteConfig = await createVite(
{
mode: 'development',
mode: inlineConfig?.mode || 'development',
server: { host, headers, open },
optimizeDeps: {
include: rendererClientEntries,
Expand Down
12 changes: 12 additions & 0 deletions packages/astro/test/units/dev/dev.test.js
Expand Up @@ -273,4 +273,16 @@ describe('dev container', () => {
assert.equal(r.res.statusCode, 200);
});
});

it('overrides mode when CLI flag is specified', async () => {
await runInContainer({ inlineConfig: { mode: 'staging' } }, (container) => {
assert.equal(container.viteServer.config.mode, 'staging');
});
});

it('uses "development" mode when CLI flag is not specified', async () => {
await runInContainer({}, (container) => {
assert.equal(container.viteServer.config.mode, 'development');
});
});
});

0 comments on commit a987a1f

Please sign in to comment.