This plugin is used to import on demand.
npm install -D babel-plugin-reduce-import
{
presets: []
plugins: [
['babel-plugin-reduce-import', {
library: 'antd',
directory: 'lib', // default to 'lib'
namingRule: 'dash', // 'little-camel', 'big-camel', 'dash', 'underline', function, default to 'big-camel'.
importDefault: false, // default to true.
style: { // true or object, default to null.
directory: 'style', // 'style' or '/less/component', default to upper directory.
namingRule: 'index', // 'little-camel', 'big-camel', 'dash', 'underline', string, function, default to null.
ext: 'css' // js, css, less, sass, default to null.
}
}]
]
}
Use for antd.
Use for material-ui.
Use for elementalui
{
library,
directory,
namingRule,
style: {
directory,
namingRule,
extension
}
}
string, default to null.
Set library name.
string, default to 'lib'.
Set component directory.
'little-camel', 'big-camel', 'dash', 'underline' or function, default to 'big-camel'.
boolean, default to true. Transform import type to default.
boolean or object, default to false. import related style file and set import mode with style.
string, default to component directory. Set style directory.
'little-camel', 'big-camel', 'dash', 'underline', custom string or function, default to null.
string, default to null. style file extension, example 'css', 'less', 'sass' or 'js'.