-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more plugins support used as environment plugin (#2994)
- Loading branch information
Showing
15 changed files
with
148 additions
and
54 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,24 @@ | ||
import { build, rspackOnlyTest } from '@e2e/helper'; | ||
import { expect } from '@playwright/test'; | ||
|
||
rspackOnlyTest('should build basic Vue jsx correctly', async ({ page }) => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
runServer: true, | ||
}); | ||
|
||
const reactUrl = new URL(`http://localhost:${rsbuild.port}/react`); | ||
|
||
await page.goto(reactUrl.href); | ||
|
||
await expect(page.locator('#test')).toHaveText('Hello Rsbuild!'); | ||
|
||
const vueUrl = new URL(`http://localhost:${rsbuild.port}/vue`); | ||
|
||
await page.goto(vueUrl.href); | ||
|
||
const button1 = page.locator('#button1'); | ||
await expect(button1).toHaveText('A: 0'); | ||
|
||
await rsbuild.close(); | ||
}); |
32 changes: 32 additions & 0 deletions
32
e2e/cases/environments/vue-react-plugins/rsbuild.config.ts
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 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginBabel } from '@rsbuild/plugin-babel'; | ||
import { pluginReact } from '@rsbuild/plugin-react'; | ||
import { pluginVue } from '@rsbuild/plugin-vue'; | ||
import { pluginVueJsx } from '@rsbuild/plugin-vue-jsx'; | ||
|
||
export default defineConfig({ | ||
environments: { | ||
react: { | ||
plugins: [pluginReact()], | ||
source: { | ||
entry: { | ||
react: './src/react/index.ts', | ||
}, | ||
}, | ||
}, | ||
vue: { | ||
plugins: [ | ||
pluginVue(), | ||
pluginVueJsx(), | ||
pluginBabel({ | ||
include: /\.(?:jsx|tsx)$/, | ||
}), | ||
], | ||
source: { | ||
entry: { | ||
vue: './src/vue/index.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,3 @@ | ||
const App = () => <div id="test">Hello Rsbuild!</div>; | ||
|
||
export default App; |
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,9 @@ | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import App from './App'; | ||
|
||
const container = document.getElementById('root'); | ||
if (container) { | ||
const root = createRoot(container); | ||
root.render(React.createElement(App)); | ||
} |
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 { defineComponent, ref } from 'vue'; | ||
|
||
export default defineComponent({ | ||
name: 'Test', | ||
|
||
setup() { | ||
const count = ref(0); | ||
return () => ( | ||
<button id="button1" type="button" onClick={() => count.value++}> | ||
A: {count.value} | ||
</button> | ||
); | ||
}, | ||
}); |
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 @@ | ||
import { createApp } from 'vue'; | ||
import A from './A'; | ||
|
||
console.log(A); | ||
|
||
createApp(A).mount('#root'); |
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
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
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