south plus soul /index.php 南+入口检测

本文介绍了如何进行webpack项目的入口检测和利用splitChunks优化配置,包括基础包、单页面依赖和自动分割公共模块的策略,以提高项目性能和缓存效果。

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

south plus soul /index.php 南+入口检测

名片进入公众号【娱乐857】

即可获取完整版资料

2018-12-24-----2021-02-18

69.171.227.37

PING https://1024td.com  @email.gmail.com.e9p.work

PING https://1024td.com  @email.gmail.com.e9p.work

optimization: {
    splitChunks: {
        ...
        
        // 项目基础包
        'vendor': {
            test: /node_modules\/vue/,
            name: 'vendor',
            chunks: 'all',
            enforce: true,
            priority: 2
        },
        // 单页面需要引入vue-router, vuex,这里单独分割出来
        'spa-vendor': {
            test: /node_modules\/vue-router/g,
            name: 'spa-vendor',
            chunks: 'all',
            enforce: true, 
            priority: 10
        },
          
        ...
    }
},
复制代码好了,到这里,我们已经把项目一些比较大的,不常变更的包独立分割出来并且做到持久缓存了,那剩余的大小不那么大的包我们就可以让webpack根据大小和引用率去自动打包了,这里我们加一个commons包的配置
optimization: {
    splitChunks: {
        ...
        
        // 项目基础包
        'vendor': {
            test: /node_modules\/vue/,
            name: 'vendor',
            chunks: 'all',
            enforce: true,
            priority: 2
        },
        // 单页面需要引入vue-router, vuex,这里单独分割出来
        'spa-vendor': {
            test: /node_modules\/vue-router/g,
            name: 'spa-vendor',
            chunks: 'all',
            enforce: true, 
            priority: 10
        },
        // 剩余chunk自动分割
        'commons': {
            name: 'commons',
            minChunks: 5, // 引用次数大于5则打包进commons
            minSize: 3000, // chunk大小大于这个值才允许打包进commons
            chunks: 'all',
            enforce: true,
            priority: 1
        }
        ...
    }
},

链接:https://1024td.com/p?1209

来源:资源库之家

著作权归作者所有。非商业转载注明出处。

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值