-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: legacy no resolve asset urls (#9507)
- Loading branch information
Showing
15 changed files
with
261 additions
and
72 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
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
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,23 @@ | ||
import type { Plugin } from '../plugin' | ||
|
||
/** | ||
* make sure systemjs register wrap to had complete parameters in system format | ||
*/ | ||
export function completeSystemWrapPlugin(): Plugin { | ||
const SystemJSWrapRE = /System.register\(.*\((exports)\)/g | ||
|
||
return { | ||
name: 'vite:force-systemjs-wrap-complete', | ||
|
||
renderChunk(code, chunk, opts) { | ||
if (opts.format === 'system') { | ||
return { | ||
code: code.replace(SystemJSWrapRE, (s, s1) => | ||
s.replace(s1, 'exports, module') | ||
), | ||
map: null | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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,32 @@ | ||
<script> | ||
import { defineComponent, defineAsyncComponent } from 'vue' | ||
import css from './inline.css?inline' | ||
export default defineComponent({ | ||
components: { | ||
module: defineAsyncComponent(() => import('./module.vue')) | ||
}, | ||
setup() { | ||
return { | ||
css | ||
} | ||
} | ||
}) | ||
</script> | ||
<template> | ||
<div class="main"> | ||
<p>Main.vue</p> | ||
<module /> | ||
<code> | ||
{{ css }} | ||
</code> | ||
</div> | ||
</template> | ||
<style scoped> | ||
.main { | ||
height: 100vh; | ||
background: url('@/assets/asset.png') no-repeat; | ||
background-size: contain; | ||
background-position: center; | ||
} | ||
</style> |
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 @@ | ||
import { test } from 'vitest' | ||
import { getBg, untilUpdated } from '~utils' | ||
|
||
test('vue legacy assets', async () => { | ||
await untilUpdated(() => getBg('.main'), 'assets/asset', true) | ||
}) | ||
|
||
test('async vue legacy assets', async () => { | ||
await untilUpdated(() => getBg('.module'), 'assets/asset', true) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
declare module '*.png' |
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,7 @@ | ||
<div id="app" style="background: 'white'"></div> | ||
<script type="module"> | ||
import { createApp } from 'vue' | ||
import App from './Main.vue' | ||
|
||
createApp(App).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,3 @@ | ||
.inline-css { | ||
color: #0088ff; | ||
} |
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,13 @@ | ||
<template> | ||
<div class="module"> | ||
<p>module.vue</p> | ||
</div> | ||
</template> | ||
<style scoped> | ||
.module { | ||
height: 100vh; | ||
background: url('@/assets/asset.png') no-repeat; | ||
background-size: contain; | ||
background-position: center; | ||
} | ||
</style> |
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,18 @@ | ||
{ | ||
"name": "test-vue-legacy", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"debug": "node --inspect-brk ../../packages/vite/bin/vite", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"vue": "^3.2.37" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "workspace:*", | ||
"@vitejs/plugin-legacy": "workspace:*" | ||
} | ||
} |
Oops, something went wrong.