Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: __VITE_PRELOAD__ replacement error (#4163)
Fixes #3051
- Loading branch information
Showing
9 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { isBuild } from '../../testUtils' | ||
|
||
test('should have no 404s', () => { | ||
browserLogs.forEach((msg) => { | ||
expect(msg).not.toMatch('404') | ||
}) | ||
}) | ||
|
||
if (isBuild) { | ||
test('dynamic import', async () => { | ||
let appHtml = await page.content() | ||
expect(appHtml).toMatch('This is <b>home</b> page.') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div id="app"></div> | ||
<script type="module"> | ||
import { createApp } from 'vue' | ||
import router from './router.js' | ||
import App from './src/App.vue' | ||
|
||
createApp(App).use(router).mount('#app') | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "test-preload", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"debug": "node --inspect-brk ../../vite/bin/vite", | ||
"serve": "vite preview" | ||
}, | ||
"dependencies": { | ||
"vue": "^3.0.8", | ||
"vue-router": "^4.0.6" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^1.0.0", | ||
"@vue/compiler-sfc": "^3.0.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createRouter, createWebHashHistory } from 'vue-router' | ||
import Home from './src/components/Home.vue' | ||
|
||
const routes = [ | ||
{ path: '/', name: 'Home', component: Home }, | ||
{ | ||
path: '/about', | ||
name: 'About', | ||
component: () => import('./src/components/About.vue') | ||
} // Lazy load route component | ||
] | ||
|
||
export default createRouter({ | ||
routes, | ||
history: createWebHashHistory() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<router-view></router-view> | ||
</template> | ||
|
||
<script setup> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<div> | ||
This is <b>about</b> page. | ||
<br> | ||
Go to <router-link to="/">Home</router-link> page | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<div> | ||
This is <b>home</b> page. | ||
<br> | ||
Go to <router-link to="/about">About</router-link> page | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const vuePlugin = require('@vitejs/plugin-vue') | ||
|
||
module.exports = { | ||
plugins: [vuePlugin()], | ||
build: { | ||
terserOptions: { | ||
format: { | ||
beautify: true | ||
}, | ||
compress: { | ||
passes: 3 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters