Ability to import source as raw/url #2665
-
I have a form where user should upload file in
It works in But seems like it doesn't work:
Is it supported? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Try this: // rsbuild.config.ts
export default defineConfig({
tools: {
rspack: {
module: {
rules: [
{
resourceQuery: /url$/,
type: 'asset/resource',
},
{
resourceQuery: /raw$/,
type: 'asset/source',
},
],
},
},
},
}); |
Beta Was this translation helpful? Give feedback.
-
@chenjiahan Thanks for this solution, when I configure it like this and try to import a Expected raw code: // src/hello-world.tsx
export const HelloWorld = () => {
return <div>Hello world</div>
}; Usage: // src/index.tsx
import Source from './hello-world?raw'; value of import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
export const HelloWorld = ()=>{
return /*#__PURE__*/ _jsxDEV("div", {
children: "Hello world"
}, void 0, false, {
fileName: "...",
lineNumber: 2,
columnNumber: 10
}, this);
};
_c = HelloWorld;
var _c;
$RefreshReg$(_c, "HelloWorld");
function $RefreshSig$() {
return $ReactRefreshRuntime$.createSignatureFunctionForTransform();
}
function $RefreshReg$(type, id) {
$ReactRefreshRuntime$.register(type, __webpack_module__.id + "_" + id);
}
Promise.resolve().then(function() {
$ReactRefreshRuntime$.refresh(__webpack_module__.id, __webpack_module__.hot);
}); |
Beta Was this translation helpful? Give feedback.
-
Rsbuild v1.4.0-beta.1 now provides built-in support for |
Beta Was this translation helpful? Give feedback.
Try this: