Recently, I started using reactjs
along with a backbonejs
router to build an application.
I usually use use requirejs
for depe
React tools (JSX included) have been deprecated in favor of Babel (https://facebook.github.io/react/blog/2015/06/12/deprecating-jstransform-and-react-tools.html). I cannot find a way to do this without a "transpiling" step, so this is my solution with grunt.
You can instal grunt-babel (npm install grunt-babel) and configure a task like the following:
babel: {
options: {
sourceMap: false,
modules: "common"
},
dist: {
files: [{
expand: true,
src: ['js/components/*.jsx'],
dest: 'dist',
ext:'.js'
}]
}
}
Just add it to your list of grunt tasks:
grunt.registerTask('default', ['clean', 'copy', 'babel', 'http-server']);
Babel will transpile your JSX to JS files that can be specified as RequireJS dependencies with no additional configuration.