Closed whatisjasongoldstein closed 8 years ago
Reactify doesn't seem to provide an option to set the JSX pragma. I would recommend using babelify
to do your JSX transformation instead, since that's the officially supported method both for react and preact. For Babel 6, you need to install babel-preset-react
, and then tell the JSX plugin to use h
for JSX.
Example .babelrc
:
{
"presets": ["react"],
"plugins": [
["transform-react-jsx",{"pragma":"h"}]
]
}
Let me know if that makes sense!
Yes, that worked. Thanks!
Awesome :)
Hi, i am new to preact. After reading comments above, i still cannot figure out how to compile jsx for preact. I used to use
gulp.src('*.jsx')
.pipe(react())
.pipe(gulp.dest('dist/js'))
to compile it.
So what should I replace react()
with?
@whatisjasongoldstein could you please post what you did to make it work?
I would but unfortunately I'm not even sure which project I was working in when I asked the question. From the comments, I think the .babelrc
file, which configures babel in the directory, was the only thing I was missing.
Hi,
I love the idea, but I'm not sure how to get it to compile jsx for preact.
This is my gulp task:
If I added
reactify
to the transforms, it compiled, but transformed my code intoReact.createElement
.I'm obviously way off course. What's the right way to do this?