Require jsx files without specifying extension

戏子无情 提交于 2019-11-30 09:01:49

Edit (April 27, 2015): I just noticed that in the question, I had an invalid argument for extension, like so:

"watch": "watchify ./src/App.js --extension=jsx -o dist/script.js -v -d"

It should be (notice the . (dot) in --extension=.jsx):

"watch": "watchify ./src/App.js --extension=.jsx -o dist/script.js -v -d"

Original Answer:

Adding in the browserify option to package.json did it for browserify but not for watchify.

"scripts": {
  "build": "browserify ./src/App.js > dist/script.js -v -d",
  "watch": "watchify ./src/App.js -o dist/script.js -v -d"
},
"browserify": {
  "extension": [ "jsx" ],
  "transform": [ [ "reactify", { "es6": true } ] ]
}

Add in the extension option for the watch command made watchify work.

"watch": "watchify ./src/App.js --extension=.jsx -o dist/script.js -v -d"

However, non-DRY. I'd like to keep my commands short as possible, but ~oh well~.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!