admin管理员组文章数量:1296239
I used create-react-app
to build a project and Babel es packaged with the installation. Usually .babelrc
file is located in the root of the project but I don't see one there. I need to modify one of the presets in the file but cannot seem to find it.
Do I need to manually create the .babelrc
file or is it already included? If so what is the location of the file?
I used create-react-app
to build a project and Babel es packaged with the installation. Usually .babelrc
file is located in the root of the project but I don't see one there. I need to modify one of the presets in the file but cannot seem to find it.
Do I need to manually create the .babelrc
file or is it already included? If so what is the location of the file?
1 Answer
Reset to default 9create-react-app
utilizes the babel-runtime
plugin to run babel through its own webpack settings in the react-scripts
package.
In the webpack file itself (./node_modules/react-scripts/config/webpack.config.dev.js
), it has .babelrc
set to false:
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
// @remove-on-eject-begin
babelrc: false,
presets: [require.resolve('babel-preset-react-app')],
// @remove-on-eject-end
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
},
Unfortunately, if you need to edit something...you will most likely have to eject with npm run eject
to get access to the webpack files.
本文标签: javascriptWhat is the location of babelrc file when using createreactappStack Overflow
版权声明:本文标题:javascript - What is the location of .babelrc file when using create-react-app? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741635159a2389598.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论