-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin-svgr): support for react query (#1783)
- Loading branch information
1 parent
4d8b102
commit 6683ffb
Showing
10 changed files
with
376 additions
and
89 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 { expect, test } from '@playwright/test'; | ||
import { build, gotoPage } from '@e2e/helper'; | ||
|
||
test('should import default from SVG with react query correctly', async ({ | ||
page, | ||
}) => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
runServer: true, | ||
}); | ||
|
||
await gotoPage(page, rsbuild); | ||
|
||
await expect( | ||
page.evaluate(`document.getElementById('component').tagName === 'svg'`), | ||
).resolves.toBeTruthy(); | ||
|
||
// test svg asset | ||
await expect( | ||
page.evaluate(`document.getElementById('url').src`), | ||
).resolves.toMatch(/http:/); | ||
|
||
await rsbuild.close(); | ||
}); |
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 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginReact } from '@rsbuild/plugin-react'; | ||
import { pluginSvgr } from '@rsbuild/plugin-svgr'; | ||
|
||
export default defineConfig({ | ||
plugins: [pluginReact(), pluginSvgr()], | ||
}); |
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 @@ | ||
import url from './small.svg?url'; | ||
import Component from './small.svg?react'; | ||
|
||
function App() { | ||
return ( | ||
<div> | ||
<Component id="component" /> | ||
<img id="url" src={url} alt="url" /> | ||
</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)); | ||
} |
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
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
Oops, something went wrong.