Webpack实现按需打包Lodash的几种方法详解
参考链接:https://www.jb51.net/article/113235.htm
在vue-cli3中需要将babel-preset-es2015插件更换为@babel/preset-env插件:
module.exports = { presets: [ [ '@vue/app', // 兼容IE配置 { useBuiltIns: 'entry' } ], ['@babel/preset-env', { modules: false }] ], plugins: [ // babel-plugin-equire:按需加载echarts 'equire', 'lodash', // babel-plugin-component:按需加载element-ui [ 'component', { libraryName: 'element-ui', styleLibraryName: 'theme-chalk' } ] ] };