我尝试将 react-toolbox 与 webpack 4 和 react 16 一起使用,但我在加载 react-toolbox 依赖项时遇到问题,它们不需要 prop-types,尽管它存在于 node_modules 中:我收到错误消息:
https://monosnap.com/file/iUQAtohH4Zuv9uKeNSXqkJWG8IOZ5U
这是我的 webpack 规则:
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader'
},{
// react-toolbox
test: /\.css$/,
include: Path.join(Config.node_modules, 'react-toolbox'),
use: [
{
loader: 'css-loader',
options: {
modules: true,
sourceMap: true,
importLoaders: 1,
localIdentName: '[name]--[local]--[hash:base64:8]'
}
},
'postcss-loader'
]
},
我的 postcss.config.js:
module.exports = {
plugins: {
'postcss-cssnext': {
features: {
customProperties: {
variables: {
'animation-duration': '0.3s',
'color-primary': '#00a6ba',
'color-accent': 'var(--palette-pink-a200)',
'color-accent-dark': 'var(--palette-pink-700)',
'color-primary-contrast': 'var(--color-dark-contrast)',
'color-accent-contrast': 'var(--color-dark-contrast)',
}
}
}
}
}
};
我的 package.json:
"prop-types": "15.6.2",
"react": "16.8.6",
"react-dom": "16.8.6",
"react-intl": "2.9.0",
"react-redux": "7.0.3",
"react-router": "5.0.0",
"react-router-dom": "5.0.0",
"react-router-redux": "4.0.8",
"react-toolbox": "^2.0.0-beta.13",