Antd Icon减少打包大小 Antd dist Chunk 打包过大 AntdIcon 按需打包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 新建 src/icons.js
// export 你想使用的图标
export {
default as SmileOutline
} from '@ant-design/icons/lib/outline/SmileOutline';
export {
default as MehOutline
} from '@ant-design/icons/lib/outline/MehOutline';

// export what antd other components need
export {
default as CloseOutline
} from '@ant-design/icons/lib/outline/CloseOutline';
// and other icons...
1
2
3
4
5
6
7
8
9
10
// vue.config.js
module.exports = {
configureWebpack: {
resolve: {
alias: {
"@ant-design/icons/lib/dist$": path.resolve(__dirname, "./src/icons.js")
}
}
}
};

新建的icons.js 随便放,注意 resolve 中文件的位置

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×