在我的项目中,我正在使用带有require钩子的Babel 6.我需要加载我写的自定义babel插件.但我是否真的需要首先使用npm发布我的插件,然后在我的主项目中包含插件名称.babelrc?
有没有办法直接加载插件代码?换句话说,我可以直接加载以下内容吗?
export default function({types: t }) {
return {
visitor: {
...
}
};
}
Run Code Online (Sandbox Code Playgroud)
小智 21
如果您在.babelrc中列出插件,请提供插件的路径,而不是标准发布的插件名称.
"plugins": ["transform-react-jsx", "./your/plugin/location"]
Run Code Online (Sandbox Code Playgroud)
导出插件功能时,您可能需要使用module.exports =而不是export default,因为ES2015模块尚未在Node中完全实现.
| 归档时间: |
|
| 查看次数: |
3100 次 |
| 最近记录: |