mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
Fix: The problem getViteConfig() duplicates some config (#12312)
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> Co-authored-by: bluwy <bjornlu.dev@gmail.com>
This commit is contained in:
parent
0cfc69d499
commit
5642ef9029
3 changed files with 19 additions and 2 deletions
5
.changeset/slimy-sloths-fry.md
Normal file
5
.changeset/slimy-sloths-fry.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes an issue where using `getViteConfig()` returns incorrect and duplicate configuration
|
|
@ -21,9 +21,8 @@ export function vitePluginMiddleware({ settings }: { settings: AstroSettings }):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: '@astro/plugin-middleware',
|
name: '@astro/plugin-middleware',
|
||||||
config(opts, { command }) {
|
config(_, { command }) {
|
||||||
isCommandBuild = command === 'build';
|
isCommandBuild = command === 'build';
|
||||||
return opts;
|
|
||||||
},
|
},
|
||||||
async resolveId(id) {
|
async resolveId(id) {
|
||||||
if (id === MIDDLEWARE_MODULE_ID) {
|
if (id === MIDDLEWARE_MODULE_ID) {
|
||||||
|
|
|
@ -2,6 +2,8 @@ import assert from 'node:assert/strict';
|
||||||
import { before, describe, it } from 'node:test';
|
import { before, describe, it } from 'node:test';
|
||||||
import * as cheerio from 'cheerio';
|
import * as cheerio from 'cheerio';
|
||||||
import { loadFixture } from './test-utils.js';
|
import { loadFixture } from './test-utils.js';
|
||||||
|
import { getViteConfig } from '../dist/config/index.js'
|
||||||
|
import { resolveConfig } from 'vite';
|
||||||
|
|
||||||
describe('Vite Config', async () => {
|
describe('Vite Config', async () => {
|
||||||
let fixture;
|
let fixture;
|
||||||
|
@ -21,3 +23,14 @@ describe('Vite Config', async () => {
|
||||||
assert.match($('link').attr('href'), /\/assets\/testing-[a-z\d]+\.css/);
|
assert.match($('link').attr('href'), /\/assets\/testing-[a-z\d]+\.css/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("getViteConfig", () => {
|
||||||
|
it("Does not change the default config.", async () => {
|
||||||
|
const command = "serve";
|
||||||
|
const mode = "test";
|
||||||
|
const configFn = getViteConfig({});
|
||||||
|
const config = await configFn({ command, mode });
|
||||||
|
const resolvedConfig = await resolveConfig(config, command, mode);
|
||||||
|
assert.deepStrictEqual(resolvedConfig.resolve.conditions, ["astro"]);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue