Skip to content

Commit 93eb1a5

Browse files
committed
test: add failing snap test for vp run build with plugins factory
Reproduces the bug where VP_COMMAND stays as 'run' when vp run synthesizes a vp build subcommand in-session, causing defineConfig to skip the plugins factory.
1 parent eb8bb0b commit 93eb1a5

6 files changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!doctype html>
2+
<html>
3+
<body>
4+
<script type="module">
5+
console.log('hello');
6+
</script>
7+
</body>
8+
</html>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function myPlugin() {
2+
return {
3+
name: 'my-run-build-plugin',
4+
transformIndexHtml(html: string) {
5+
return html.replace('</body>', '<!-- run-build-plugin-injected --></body>');
6+
},
7+
};
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "vite-plugins-run-build-test",
3+
"private": true,
4+
"scripts": {
5+
"build-task": "vp build"
6+
}
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
> vp run build-task
2+
[1]> cat dist/index.html | grep 'run-build-plugin-injected' # vp run build should load plugins from factory
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"commands": [
3+
{
4+
"command": "vp run build-task",
5+
"ignoreOutput": true
6+
},
7+
"cat dist/index.html | grep 'run-build-plugin-injected' # vp run build should load plugins from factory"
8+
]
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from 'vite-plus';
2+
3+
export default defineConfig({
4+
plugins: async () => {
5+
const { default: myPlugin } = await import('./my-plugin');
6+
return [myPlugin()];
7+
},
8+
});

0 commit comments

Comments
 (0)