我有一个在 React 应用程序中使用的 React 组件库。组件库是使用 Styleguidist 和 webpack 设置的。我已经将 webpack 设置为使用绝对路径:
webpackConfig: {
resolve: {
modules: [path.resolve(__dirname, 'src/'), 'node_modules'],
}
}
这在组件库的上下文中起作用。当我build
组件库时,包看起来像这样:
/core
/components
/Table
/Row
当我import
将组件放入我的应用程序时,我收到一个错误:
Module not found: Can't resolve components/Row in /Users/myusername/Sites/mysite/node_modules/@mypackage/core/components/Table
我理解为什么路径在 的上下文中不匹配node_modules
,但我希望 Webpack 在构建过程中转换这些导入路径。有什么我想念的吗?或者这是不可能的?