ReactJS uses a special syntax called JSX, not the normal JS one. Usually, when you want to work with ReactJS JSX files, you need to transform it to a normal JS file and then operate on that file. However, with the help of Reactify, a transform for Browserify, you won’t need to compile jsx to js files anymore, just use it directly from your code.
For example, I have two files: view.jsx and main.js. view.jsx
contains the definition for React view and main.js is the website’s main
script that loads the view through require()
.
- view.jsx
- main.js
Next, create a Gulp task for compiling main.js using Browserify
After you run this task (using gulp browserify
), the output file will be
placed in ./dist folder.