安装babel-plugin-import依赖
npm install --save babel-plugin-import
vue
配置babel.config.js
module.exports = {
plugins: [
['import', {
libraryName: 'vant',
libraryDirectory: 'es',
style: true
}, 'vant']
]
};
react next.js
根目录新建配置 .babelrc
{
"presets": ["next/babel"],
"plugins": [
[
"import",
{
"libraryName":"antd",
"style":"css"
}
]
]
}
代码中按需引入
// vue
import {Button} from 'vant'
// react
import {Button} from 'antd'
关于react打包的问题:https://blog.csdn.net/qq_37034928/article/details/106382883