-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: different production base path does not work
add test-case which uses a base-path
- Loading branch information
1 parent
2d42d0f
commit b6fbb4a
Showing
8 changed files
with
70 additions
and
6 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 { readFile, untilUpdated, isBuild } from '../../testUtils' | ||
|
||
test('should work', async () => { | ||
await page.click('.clickme') | ||
await untilUpdated(() => page.textContent('.content'), '3', true) | ||
}) | ||
|
||
if (isBuild) { | ||
test('should have relative path', async () => { | ||
expect(readFile('dist/foo/assets/index.js')).toMatch( | ||
/.*\.\/assets\/preload\.js.*/ | ||
) | ||
}) | ||
} |
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,5 @@ | ||
import preload from './preload' | ||
|
||
export function test() { | ||
return 1 + preload() | ||
} |
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,4 @@ | ||
<script type="module" src="./main.js"></script> | ||
|
||
<button class="clickme">Click me</button> | ||
<div class="content"></div> |
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,4 @@ | ||
document.querySelector('.clickme').addEventListener('click', async () => { | ||
const { test } = await import('./dep.js') | ||
document.querySelector('.content').textContent = test() | ||
}) |
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,11 @@ | ||
{ | ||
"name": "base-path", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"debug": "node --inspect-brk ../../vite/bin/vite", | ||
"serve": "vite preview" | ||
} | ||
} |
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,3 @@ | ||
export default function () { | ||
return 2 | ||
} |
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,24 @@ | ||
const { resolve } = require('path') | ||
|
||
/** | ||
* @type {import('vite').UserConfig} | ||
*/ | ||
module.exports = { | ||
base: '/foo/', | ||
build: { | ||
// simulate production environment | ||
outDir: 'dist/foo', | ||
// prevent bundling of dep and preload to ensure that vite-preloading occurs | ||
rollupOptions: { | ||
input: [ | ||
resolve(__dirname, 'index.html'), | ||
resolve(__dirname, 'preload.js'), | ||
resolve(__dirname, 'dep.js') | ||
], | ||
// use simple entry names for easier reference inside the tests | ||
output: { | ||
entryFileNames: 'assets/[name].js' | ||
} | ||
} | ||
} | ||
} |
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