[英]What is the location of .babelrc file when using create-react-app?
I used create-react-app
to build a project and Babel comes packaged with the installation.我使用
create-react-app
构建了一个项目,Babel 与安装一起打包。 Usually .babelrc
file is located in the root of the project but I don't see one there.通常
.babelrc
文件位于项目的根目录中,但我在那里没有看到。 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?我需要手动创建
.babelrc
文件还是已经包含它? If so what is the location of the file?如果是这样,文件的位置是什么?
create-react-app
utilizes the babel-runtime
plugin to run babel through its own webpack settings in the react-scripts
package. create-react-app
利用babel-runtime
插件通过react-scripts
包中自己的 webpack 设置运行 babel。
In the webpack file itself ( ./node_modules/react-scripts/config/webpack.config.dev.js
), it has .babelrc
set to false:在 webpack 文件本身(
./node_modules/react-scripts/config/webpack.config.dev.js
)中,它的.babelrc
设置为 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.不幸的是,如果你需要编辑一些东西......你很可能必须使用
npm run eject
才能访问 webpack 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.