Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions packages/plugin-rsc/e2e/root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,50 @@ test.describe(() => {
defineStarterTest(f)
})
})

// Test that the RSC plugin works when `root` is passed as a CLI argument
// e.g. `vite dev ./app` where the app lives in a subdirectory.
// This effectively tests `createServer/createBuilder({ root })`
// and then loading config file from the specified root.
test.describe('root-config', () => {
const root = 'examples/e2e/temp/root-config'

test.beforeAll(async () => {
await setupInlineFixture({
src: 'examples/starter',
dest: `${root}/app`,
files: {
'vite.config.base.ts': { cp: 'vite.config.ts' },
'vite.config.ts': /* js */ `
import baseConfig from './vite.config.base.ts'
import path from "node:path";
for (const e of Object.values(baseConfig.environments)) {
e.build.rollupOptions.input.index = path.resolve(
'app',
e.build.rollupOptions.input.index,
);
}
export default baseConfig;
`,
},
})
})

test.describe('dev', () => {
const f = useFixture({ root, mode: 'dev', command: 'vite dev ./app' })
const oldCreateEditor = f.createEditor
f.createEditor = (filePath: string) =>
oldCreateEditor(path.resolve(root, 'app', filePath))
defineStarterTest(f)
})

test.describe('build', () => {
const f = useFixture({
root,
mode: 'build',
buildCommand: 'vite build ./app',
command: 'vite preview ./app',
})
defineStarterTest(f)
})
})
Loading