优化:忽略依赖中不必要的语言包
yarn add moment webpack-dev-server -D
忽略掉moment
的其他语言包
let webpack = require('webpack')
plugins: [
new webpack.IgnorePlugin(/\.\/locale/, /moment/)
]
index.js
import moment from 'moment'
let r = moment().endOf('day').fromNow() // 距离现在多少天
console.log(r);
从 1.2MB 到 800kb