如何配置React来渲染.js

时间:2015-12-10 07:46:28

标签: reactjs webstorm rubymine

我试图让WebStorm为我观看.jsx文件呈现.js文件。

我正在使用或尝试使用browserify / babelify并对节点做出反应,但我收到以下错误

/usr/local/bin/browserify -t [babelify --presets react]
/Users/myUser/Developer/ApacheRoot/JsFrameworksSamples/ReactJs/Sample_2/src/*
-o /Users/myUser/Developer/ApacheRoot/JsFrameworksSamples/ReactJs/Sample_2/src/bundle.js
Error: Cannot find module
'/Users/myUser/Developer/ApacheRoot/JsFrameworksSamples/ReactJs/Sample_2/src/*'
from
<br>'/Users/myUser/Developer/ApacheRoot/JsFrameworksSamples/ReactJs/Sample_2/src'
    at <br>/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:55:21
    at load <br>(/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
    at onex <br>(/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
    at <br>/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
    at<br> FSReqWrap.oncomplete (fs.js:95:15)<br>

Process finished with exit code 1

文件观察程序的配置如下:

enter image description here

参数:-t [babelify --presets react] $FileDir$/* -o $FileDir$/bundle.js

我做错了什么?

1 个答案:

答案 0 :(得分:1)

好的....我得到了解决方案......

browseify不能使用通配符(如*),因此它应使用以下参数转换单个文件:

  

-t [babelify --presets react] $ FileDir $ / $ FileNameWithoutExtension $ .jsx -o $ FileDir $ / .. / dist / $ FileNameWithoutExtension $ .js

之后,当您要捆绑所有.jsx文件时,它可以运行以下命令:

  

browserify -t [babelify --presets [react]] src / * -o dist / bundle.js