根据官方推荐的配置:`{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.join(__dirname, './app'),
loader: 'babel-loader',
query: {
cacheDirectory: true,
plugins: ['transform-runtime',['import', [{ libraryName: 'antd', style: "css" }]]],
presets:['es2015','react','stage-0']
}
}`
然后各个路由按需加载。如图:
这是还没开启UglifyJsPlugin压缩。有1.5M。在page_a中这样引入antd:
import { Form, Table, Input, Button,Breadcrumb,Badge,Dropdown,Menu,Icon } from 'antd';
开启UglifyJsPlugin压缩后如下图:
还是有900多k。请问在后端gzip压缩之前还能进一步缩小体积么?
猛跑小猪
相关分类