We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
记录一下当前vue工程下使用的优化(vue-cli3):
方案一:替换为date-fns或dayjs,参考You-Dont-Need-Momentjs (翻译版)
方案二:使用ignorePlugin删除它国际化的部分,具体操作: 在vue.config.js中加入如下配置:
const webpack = require('webpack'); module.exports = { chainWebpack: config => { config .plugin('ignorePlugin') .use(webpack.IgnorePlugin, [{ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/, }]); }, }
使用方式:
const moment = require('moment'); // 引入zh-cn locale文件 require('moment/locale/zh-cn'); moment.locale('zh-cn');
缩减后,大致会缩减至原来的四分之一
方法一:单独引入
import {chain, cloneDeep} from 'lodash'; // 可以改写为 import chain from 'lodash/chain'; import cloneDeep from 'lodash/cloneDeep';
方法二:引入lodash-webpack-plugin和babel-plugin-lodash 在vue.config.js中chainWebpack加入
lodash-webpack-plugin
babel-plugin-lodash
config.plugin("loadshReplace") .use(new LodashModuleReplacementPlugin());//优化lodash
方法三:使用 lodash-es 利用tree-shaking
import {isEmpty, isObject, cloneDeep} from 'lodash-es';
参考:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
记录一下当前vue工程下使用的优化(vue-cli3):
1. moment.js
方案一:替换为date-fns或dayjs,参考You-Dont-Need-Momentjs (翻译版)
方案二:使用ignorePlugin删除它国际化的部分,具体操作:
在vue.config.js中加入如下配置:
使用方式:
缩减后,大致会缩减至原来的四分之一
2.lodash.js
方法一:单独引入
方法二:引入
lodash-webpack-plugin
和babel-plugin-lodash
在vue.config.js中chainWebpack加入
方法三:使用 lodash-es
利用tree-shaking
参考:
The text was updated successfully, but these errors were encountered: