Skip to content

Commit

Permalink
chore: add mpa example
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 8, 2024
1 parent f9a12f3 commit 90ac390
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 0 deletions.
12 changes: 12 additions & 0 deletions playground/rolldown-dev-mpa/__tests__/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { test } from 'vitest'
import { page } from '../../test-utils'

test('basic', async () => {
await page.goto('/')
await page.getByRole('heading', { name: 'Home' }).click()
await page.getByText('Rendered by /index.js').click()
await page.getByRole('link', { name: 'About' }).click()
await page.waitForURL('/about')
await page.getByRole('heading', { name: 'About' }).click()
await page.getByText('Rendered by /about/index.js').click()
})
10 changes: 10 additions & 0 deletions playground/rolldown-dev-mpa/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@vitejs/test-rolldown-dev-mpa",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}
15 changes: 15 additions & 0 deletions playground/rolldown-dev-mpa/src/about/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head></head>
<body>
<div>
<h1>About</h1>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
</div>
<div id="root"></div>
<script type="module" src="./index.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions playground/rolldown-dev-mpa/src/about/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.getElementById('root').innerHTML = `
<p>Rendered by /about/index.js: ${Math.random().toString(36).slice(2)}</p>
`
15 changes: 15 additions & 0 deletions playground/rolldown-dev-mpa/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head></head>
<body>
<div>
<h1>Home</h1>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
<div id="root"></div>
<script type="module" src="./index.js"></script>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions playground/rolldown-dev-mpa/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.getElementById('root').innerHTML = `
<p>Rendered by /index.js: ${Math.random().toString(36).slice(2)}</p>
`
23 changes: 23 additions & 0 deletions playground/rolldown-dev-mpa/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from 'vite'

export default defineConfig({
clearScreen: false,
root: './src',
environments: {
client: {
build: {
rollupOptions: {
input: {
index: './index.html',
about: './about/index.html',
},
},
},
},
},
experimental: {
rolldownDev: {
hmr: true,
},
},
})
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 90ac390

Please sign in to comment.