gpt4 book ai didi

javascript - 你能在 .babelrc 中使用正则表达式吗?

转载 作者:数据小太阳 更新时间:2023-10-29 03:55:34 24 4
gpt4 key购买 nike

这是我的 .babelrc 的样子。显然它不起作用,因为 JSON 文件中的正则表达式:

{
"presets": ["es2015", "react"],
"plugins": ["transform-object-rest-spread"],
"only": [
'/client/**/*',
'/server/**/*',
/diy-fe-shared/ // <--- regex here breaks
]
}

有没有办法在这里使用正则表达式?

最佳答案

也许你可以像这样在 .babelrc 中使用正则表达式:https://github.com/probablyup/markdown-to-jsx

创建.babelrc.js:

const plugins = [
'emotion',
];

if (process.env.NODE_ENV === 'production') {
plugins.push('transform-react-remove-prop-types');
}

module.exports = {
plugins,
presets: [
['es2015', {
loose: true,
modules: process.env.BABEL_ENV === 'esm' ? false : 'commonjs',
}],
'react',
'stage-2',
],
};

然后在.babelrc中引入.babelrc.js

{
"presets": ["./.babelrc.js"]
}

关于javascript - 你能在 .babelrc 中使用正则表达式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38442989/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com