一个轻量的按需加载库
npm install light-babel-import --save-devConverts
import { _isUrl } from 'light-utils'to
var _isUrl = require('light-utils/lib/_isUrl')Converts
import Components from 'components'
import { Button } from 'components'to
require('components/lib/styleLibraryName/index.css')
var button = require('components/lib/styleLibraryName/button.css')Via .babelrc or babel-loader.
{
"plugins": [["light-babel-import", options]]
}{
"plugins": [xxx,
["light-babel-import", {
libraryName: "antd",
style: true,
}, "antd"],
["light-babel-import", {
libraryName: "test-module",
style: true,
}, "test-module"]
]
}