Add an entry that can customize the JSX helper, it is used in the same way as thevite, before the swc works, inject a custom JSX helper into all JSX/TSX files, and with the pragma and pragmaFrag can customize any desired parsing method
For example in vue3
module: {
rules: [
{
test: /\.(tsx|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "swc-loader",
options: {
jsc: {
parser: {
syntax: "typescript"
},
transform: {
react: {
/** Use custom rendering functions, If you use the example of vue, it is */
pragma: 'h',
pragmaFrag: 'Fragment',
jsxInject:`import { h, Fragment } from 'vue'`
}
},
}
}
}
}
];
}
In addition to vue, in some custom jsx rendering functions, this is more convenient and understandable;
For example: tsx-dom
Add an entry that can customize the JSX helper, it is used in the same way as thevite, before the swc works, inject a custom JSX helper into all JSX/TSX files, and with the pragma and pragmaFrag can customize any desired parsing method
For example in vue3
In addition to vue, in some custom jsx rendering functions, this is more convenient and understandable; For example: tsx-dom