只是想知道create-react-app如何使用.js文件而不是.jsx进行jsx标记。是否由于特殊的webpack配置?顺便说一句,在哪里可以找到使用create-react-app创建的项目的webpack和babel配置?
文件扩展名没有什么特别的。这只是通过Babel运行的问题。例如:
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: [
'react',
'es2015',
'stage-0'
],
plugins: [
["transform-decorators-legacy"],
]
},
}
这会通过Babel使用React预设运行.js和.jsx。
Webpack和Babel配置位于create-react-app中。
您可以通过以下方式弹出它们:
npm run eject
让他们“外部化”,但只有在您确实愿意的情况下才这样做。
https://github.com/facebookincubator/create-react-app#user-content-converting-to-a-custom-setup
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句