我正在尝试以本question中所述的相同方式,将自己的react组件库作为npm软件包分发。就像在链接的问题中一样,我试图避免在库npm包中进行任何构建或编译。
我已经在测试项目中安装了我的组件库...
npm install -S '@mylib/widgets'
import { BasicList } from '@mylib/widgets/Lists/List'
在测试项目中,我尝试将babel-loader
配置中的webpack
配置为排除任何node_modules
软件包除外我的书架({{1)})...
@mylib/widgets
但是,当我运行rules: [
{
test: /\.(js|jsx)$/,
exclude : [/node_modules\/(?!@mylib).*/] // is this correct?
loader: 'babel-loader',
options: {
// enable caching for improved performance during development
// uses default OS dir as default
cacheDirectory: true,
},
},
],
时遇到错误,因为似乎webpack-dev-server
试图转换我的库所需的babel
软件包。
material-ui
这是我的正则表达式在exclude子句中的问题,还是预期的行为?如果是这样,有什么方法可以防止ERROR in ../node_modules/jss-nested/lib/index.jsModule build failed: Error: Couldn't find preset "stage-0" relative to directory "C:\\Users\\...\\node_modules\\jss-nested"
...
@ ../node_modules/@material-ui/core/styles/jssPreset.js 12:40-61
@ ../node_modules/@material-ui/core/styles/index.js
@ ./node_modules/@mylib/widgets/Lists/List.js
@ ./index.js
@ multi ../node_modules/webpack-dev-server/client?http://localhost:9000 webpack/hot/dev-server ./index.js
尝试移植我的库所需的软件包吗?