我正在创建一个组件库以在不同项目中使用它。我无法在npm中发布它,因此我将它们引发了关联(npm我是'../../local-lib-path')。构建主应用程序(使用库)时,它给了我以下错误,对应于库组件:
NodeInvocationException: Prerendering failed because of error: Error: Module parse failed: Unexpected token (53:4)
You may need an appropriate loader to handle this file type.
|
| return (
> <Button icon="download" onClick={getReport} {...props} > Export </Button>
|
据我了解,Webpack不会编译库中的组件。我要通过库编译吗?如何编译库(我不需要应用程序,仅导出组件)
非常感谢您的光临!
在我的库中,我像这样导入组件。在../components/App
import ExportButton from '../components/App'
export { ExportButton }
在主应用中,在我的json中,我有:
"export-buton": "file:../../components/components",
我用它
import {ExportButton} from 'export-button'