0
我可以很容易地的WebPack transpile我的代碼到單個模塊通過以下策略:導出多個從單一的編譯「文件」
{
entry: path.join(__dirname, 'src/index.js'),
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
libraryTarget: 'umd',
library: 'totem-ui',
}
}
凡我src/index.js
文件看起來如下:
export { default as Button } from 'src/atoms/Button';
這可以通過第三方應用程序如此消耗:
import { Button } from 'totem-ui';
但是,我在嘗試要完成的是類似於如何react-router
或lodash
這樣做。例如,反應的路由器,你可以導入這樣的單個模塊:
import Router from 'react-router/lib/Router';
在我的情況下,它應該是這樣的:
import Button from 'totem-ui/atoms/Button';
如何通過的WebPack這個實現的呢?這種模式叫什麼?