[英]JSX files in create-react-app
Just wondering how create-react-app uses.js files instead of.jsx for jsx markup.只是想知道 create-react-app 如何使用 .js 文件而不是 .jsx 来进行 jsx 标记。 Is it because of the special webpack configuration?
是因为webpack的特殊配置吗? Btw, where can I find the webpack and babel configuration of my project created with create-react-app?
顺便说一句,我在哪里可以找到我用 create-react-app 创建的项目的 webpack 和 babel 配置?
There's nothing special about the file extensions;文件扩展名没有什么特别之处; it's just a matter of what's being run through Babel.
这只是通过 Babel 运行什么的问题。 For example:
例如:
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: [
'react',
'es2015',
'stage-0'
],
plugins: [
["transform-decorators-legacy"],
]
},
}
This runs.js and.jsx through Babel with the React presets.这通过带有 React 预设的 Babel 运行 .js 和 .jsx。
The Webpack and Babel configs are inside create-react-app. Webpack 和 Babel 配置在 create-react-app 中。
You can eject them via:您可以通过以下方式弹出它们:
npm run eject
to get them "externalized", but only do it if you really want to. npm run eject
让它们“外部化”,但只有在你真的想要的时候才这样做。
https://github.com/facebookincubator/create-react-app#user-content-converting-to-a-custom-setup https://github.com/facebookincubator/create-react-app#user-content-converting-to-a-custom-setup
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.